The first part of this code works fine, I just can't seem to get the else statment working for when if ($row[password] == $password_hash) is false. I'm sure I only have a small error somewhere but just can't seem to find it.
list ($sessionname) = checkuser();
if (isset($_POST['save'])){
connect();
$currentpass = sha1($_POST['password']);
$newpass = sha1($_POST['password1']);
$sql = "SELECT password FROM members WHERE username = '$sessionname'";
$result=mysql_query($sql);
$row = mysql_fetch_array($result);
if ($row['password'] == $currentpass)
$query = mysql_query("UPDATE members SET password = '$newpass' WHERE username = '$_SESSION[username]'");
$updated = "Your password has been updated";
print_r($row);
}else{
$a = "Passwords do not match";
return $b;
}
}