updating database..help pls.. [SOLVED]
Posted: Mon Jan 30, 2006 10:54 am
i have these lines of codes
when i click the submit button, it returns the message "your password has been changed"...that's good...but the funny part is that, in my database, the password does not change...can you spot what maybe the problem??i scrolled to my book and i think i wrote the code right...
thanks in advance..
Code: Select all
if ($un && $pw && $pw1)
{
$query = "SELECT userID FROM users where(username='$un' AND password='$pw')";
$result = @mysql_query($query);
$num = mysql_num_rows($result);
if ($num == 1)
{
$row = mysql_fetch_array($result, MYSQL_NUM);
//make the query
$query = "UPDATE users SET password='$pw1' WHERE userID=$row[0]";
if (mysql_affected_rows() == 1)
{
echo '<p><b>Your password has been changed.</b></p>';
include('templates/footer.inc');
exit();
}
else
{
$message .= '<p>Your password could not be changed due to system error</p><p>' . mysql_error() . '</p>';
}
}
else
{
$message .= '<p>Your username and password do not match our records!</p>';
}
mysql_close();
}
else
{
$message .= '<p>Please try again!</p>';
}thanks in advance..