Hi Guys,
Having some issues with the following code for changing a users password in their profile:
[php]$todo=$_POST[‘todo’];
$password=$_POST[‘password’];
$password2=$_POST[‘password2’];
if(isset($todo) and $todo==“change-password”){
$password=mysql_real_escape_string($password);
//Setting flags for checking
$status = “OK”;
$msg="";
if ( strlen($password) < 3 or strlen($password) > 8 ){
$msg=$msg.“Password must be more than 3 char legth and maximum 8 char lenght
”;
$status= “NOTOK”;}
if ( $password <> $password2 ){
$msg=$msg.“Both passwords are not matching
”;
$status= “NOTOK”;}
if($status<>“OK”){
echo “$msg
”;
}else{ // if all validations are passed.
$db_new_password = md5($password2);
if(mysql_query(“UPDATE users SET password = ‘$db_new_password’ WHERE userid = ‘$_SESSION[userid]’”)){
echo “Thanks
Your password changed successfully. Please keep changing your password for better security”;
}else{echo “Sorry
Failed to change password Contact Site Admin”;
}
}
}[/php]
Now when submitting the form it advises that the password has been changed. But the password actually remains the same.
Any help would be greatly appreciated.
Kind Regards,
egghead0