I’m trying to edit the code for a “Edit Profile” page on my site.
On the edit profile page there is a place for a user to change their password, avatar, user details, etc.
My issue is I’m trying to get it to do is this:
If this user is changing their password, check to see if the password is a minimum of six characters and matches the “password confirmation” field.
If this user is not changing their password, but updating other fields, do nothing.
This is what I have so far. I know it’s wrong and I’m banging my head against a wall.
Thanks for any help!
[php]
if (($_POST[confirmpassword]) != ($_POST[newpassword])) {
$messages[] = “The passwords do not match!”;}
if (strlen($_POST[confirmpassword]) < 6) {
$messages[] = “Password must be at least 6 characters long.”;
}
else
{($newpass = mysql_real_escape_string(md5($_POST[newpassword])));
mysql_query(“UPDATE users SET password = ‘$newpass’ WHERE record_num = ‘$_SESSION[userid]’”);
}
if($messages === false){
mysql_query("UPDATE users SET username='".$username."',first_name = '".$first_name."',last_name = '".$last_name."',email = '".$email."',phone = '".$phone."',address_1 = '".$address_1."',address_2 = '".$address_2."',zip = '".$zip."',city = '".$city."',state = '".$state."', country = '".$country."' WHERE record_num = '$_SESSION[userid]'") or die(mysql_error());[/php]