1- your mysql query statement is better to have a WHERE part too. 2- I would use mysql_fetch_row instead of mysql_fetch_assoc 3- in your form, you're using a single quote. anything in between single quotes will be printed as is. you need to close your single quote and print username and open another single quote. Like this: '.......' . $username02 . '.........' Or I personally would close my php, print the form in html and use <?php echo $username02; ?> where you need the username. And then I would start another <? php section if I need it. Siavash Quoting Zhimmy Kanata <kanata_zhimmagish@xxxxxxxx>: > Hi, > > I am trying to pass a variable into a textfield and then pass the variable > onto a php page for insertion into a Mysql database. > > However, I want to send the username of the person logging on. But instead > php is taking the username of the logon information of the database. Which I > obviously don't want for many obvious reasons. > > Oddly enough it echo's $username02 so it shouldn't be a pass down issue. > But when the insert.php I also ask it to echo and it doesn't. > > Any suggestions? > > <?php > require("config.php"); > $sql = "SELECT `username`, `password` FROM `user_system`"; > $result = mysql_query($sql); > $check = mysql_fetch_assoc($result); > $username_to_check = mysql_real_escape_string($_POST['username']); > $password_to_check = md5($_POST['password']); > > $username02 = mysql_real_escape_string($_POST['username']); > > if ($check['username'] != $username_to_check || $check['password'] != > $password_to_check) { > echo "The username or password was wrong!"; > } > else { > > echo 'The username and password was correct! > > <form name="Your turn" method="post" action="insert.php"> > <table width="750" border="0" align="right" cellpadding="0" > cellspacing="0"> > <tr> > <td> > <input name="username" type="text" value= "$username02"> > </td> > </tr> > <tr> > <td width="372">Question 1 > </td> > > <td width="378"><div align="center"> > <select name="select1" size="1"> > <option value="1">Yes I strongly agree</option> > <option value="2">Yes I agree </option> > <option value="3">I disagree</option> > <option value="4">I strongly disagree</option> > </select> > </div> > </td> > </tr> > <tr> > <td height="87"> </td> > <td><div align="center"> > <input type="submit" name="Your turn"> > </div> > </td> > </tr> > </table> > </form> > > '; > echo "$username"; > echo "$username02"; > > } > ?> > > > --------------------------------- > The best gets better. See why everyone is raving about the All-new Yahoo! > Mail. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php