Forum Moderators: coopster
Summary:
I a beginner with PHP and I am creating a secure customer portal using php and MYSQL I am using logon scripts and storing passwords with MD5 encryption.
I am able to:
get the password to be stored into the database as MD5 and the user can log in sucessfully.
My problem:
Comes when I am trying to make a password reset form where I (the admin) can change the users password to a temporary password (cant figure out how to do this), then the user can logon with the temporary password and change the temporary password to a new one.(cant figure out how to do this either). The variable does hold the hash, but its not being updated in MySQL.
The Code:
I am trying to use the following command with no luck:
$query = "UPDATE user SET `password`='$newpassword' WHERE id='$id'";
$result = mysql_query($query);
Am I doing somthing wrong? I have tried many differnt version and ways to do this with none being sucessful.
Thank you for your time!
I assume you are sending data from a form? Do you have register globals OFF? Also, use mysql_error() to see if the query is failing in any way.
So, try this:
$query = "UPDATE user SET `password`='".$_POST['$newpassword']."' WHERE id='".$_POST['id']."'";
$result = mysql_query($query) or die(mysql_error());
dc