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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • uranuskid
    New Member
    • Mar 2007
    • 19

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

    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:
    Code:
    <?
    
    	include_once ("auth.php");
    	include_once ("authconfig.php");
    	include_once ("check.php");	
    	
    	$username = $check["uname"];	
    	
    	$result = mysql_query("SELECT email, phone, mobile FROM signup WHERE uname= '[$username]'")
                            or die("SELECT error: ".mysql_error());     // catch any error
    	$row = mysql_fetch_array($result);
                    $email = $row["email"];
    	
    ?>
    Later I want to get these results and use them in a hidden field like that:

    Code:
    <input type="hidden" name="username" value="<? print $username ?>">
    <input type="hidden" name="email" value="<? print $email ?>">
    The username is fine, but nor the email.
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    [PHP]$email = $row["email"];[/PHP]Does the $email variable actualy contain a value?

    Comment

    • uranuskid
      New Member
      • Mar 2007
      • 19

      #3
      Originally posted by code green
      [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

      Comment

      • code green
        Recognized Expert Top Contributor
        • Mar 2007
        • 1726

        #4
        Code:
        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.

        Comment

        • uranuskid
          New Member
          • Mar 2007
          • 19

          #5
          Originally posted by code green
          Code:
          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_ass oc($result)
          and returned the email variable as
          [PHP]$email = $row['email'][/PHP]

          Thanks for advising me to debugg!

          Frank

          Comment

          Working...