Posting a variable
| From: | Zhimmy Kanata | Date: | Wed, 11 Apr 2007 16:21:21 +0000 |
| Subject: | Posting a variable | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-252605@lists.php.net to get a copy of this message | ||
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.