469,277 Members | 2,063 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,277 developers. It's quick & easy.

How to store data from one db in hidden fields and enter in a second db

uranuskid
Hey guys,

I need help with following issue: I have a db where userinfos are stored. The script connects to this db in order to check whether the user is logged in. Then I have a from where people enter s.th to be stored in another db. The form transports the username as a hidden field. That's all fine, but once I want to store more info in hidden fields I somehow can't get that.Here is the code:
Expand|Select|Wrap|Line Numbers
  1. <?
  2.  
  3.     include_once ("auth.php");
  4.     include_once ("authconfig.php");
  5.     include_once ("check.php");    
  6.  
  7.     $username = $check["uname"];    
  8.  
  9.     $result = mysql_query("SELECT email, phone, mobile FROM signup WHERE uname= '[$username]'")
  10.                         or die("SELECT error: ".mysql_error());     // catch any error
  11.     $row = mysql_fetch_array($result);
  12.                 $email = $row["email"];
  13.  
  14. ?>
  15.  
Later I want to get these results and use them in a hidden field like that:

Expand|Select|Wrap|Line Numbers
  1. <input type="hidden" name="username" value="<? print $username ?>">
  2. <input type="hidden" name="email" value="<? print $email ?>">
  3.  
The username is fine, but nor the email.
Apr 9 '07 #1
4 1651
code green
1,726 Expert 1GB
[PHP]$email = $row["email"];[/PHP]Does the $email variable actualy contain a value?
Apr 10 '07 #2
[PHP]$email = $row["email"];[/PHP]Does the $email variable actualy contain a value?
Hey there,

Yeah, the $email variable should contain the value mailadress from the respective db.
Is it that I have to write the query and the the print in one php quote?

Thx,
Frank
Apr 11 '07 #3
code green
1,726 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. Yeah, the $email variable should contain the value mailadress from the respective db
No. I asked DOES it contain a value. Without any debugging you have no idea what is happening. .[PHP]echo $email;[/PHP]Anyway I have spotted a syntax [HTML]<input type="hidden" name="username" value="<? print $username ?>">
<input type="hidden" name="email" value="<? print $email ?>">[/HTML]There is no semi-colon after the php lines.
Apr 11 '07 #4
Expand|Select|Wrap|Line Numbers
  1. Yeah, the $email variable should contain the value mailadress from the respective db
No. I asked DOES it contain a value. Without any debugging you have no idea what is happening. .[PHP]echo $email;[/PHP]Anyway I have spotted a syntax [HTML]<input type="hidden" name="username" value="<? print $username ?>">
<input type="hidden" name="email" value="<? print $email ?>">[/HTML]There is no semi-colon after the php lines.
hey there,

I solved the issue:
I did a general query instead of a column query. Seelct *
Also,Instead of mysql_fetch_row I used mysql_fetch_assoc($result)
and returned the email variable as
[PHP]$email = $row['email'][/PHP]

Thanks for advising me to debugg!

Frank
Apr 17 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Hasanain F. Esmail | last post: by
1 post views Thread by Trent | last post: by
7 posts views Thread by Shadow Lynx | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.