hey everyone i\'m trying to write this script where a user can update his/her password and everything is in a function and is called through a switch statement. all of the functions work except for the function that updates the users password.
I was wondering if anyone could check out the code that i have written and see what might be wrong. i tested things out in the mysql command line and even though the script says it has updtaed the password if i try to debug it in the command line it shows that it hasnt updated.
here is the code:
function password_form() {
global $PHP_SELF;
global $userid, $username, $homepage;
global $dbhost, $dbusername, $dbuserpassword, $tablename, $default_dbname;
$connection = mysql_connect($dbhost, $dbusername, $dbuserpassword) or die (\"cannot access the $default_dbname\");
$db = mysql_select_db($default_dbname, $connection);
$query = \"SELECT * FROM $tablename WHERE username = \'$username\' AND userpassword = \'$userpassword\'\";
$result = mysql_query($query);
?>
echo \"<form name=\"password_form\" method=\"post\" action=\"<?php echo $PHP_SELF ?>\">
<input type=\"hidden\" name=\"action\" value=\"update_password\">
<input type=\"hidden\" name=\"username\" value=\"<?php echo $username ?>\">
<table width=\"300\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">
<tr>
<td align=\"right\" class=\"mttext\">userid:</td>
<td width=\"10\"> </td>
<td class=\"mttext\"><?php echo $username ?>
<br>
</td>
</tr>
<tr>
<td align=\"right\" class=\"mttext\"><br>password:</td>
<td> </td>
<td><br>
<input type=\"text\" name=\"userpassword\" class=\"fields\">
</td>
</tr>
<tr>
<td align=\"right\" class=\"mttext\"><br>retype password:</td>
<td> </td>
<td><br>
<input type=\"text\" name=\"userpassword2\" class=\"fields\">
</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>
<input type=\"submit\" name=\"submit\" value=\"change password\" class=\"buttons\">
<input type=\"reset\" name=\"reset\" value=\"clear\" class=\"buttons\">
</td>
</tr>
</table>
</form>