I have 2 tables :
newpw_askemail codeusersid username password email sid newpw_code
I have this PHP code:
$code = $_POST['code2'];
$email = mysql_query("SELECT email FROM pw_ask WHERE code='$code'");
if ($pass == $pass2) {
if ($email) {
$pass3 = md5($pass);
mysql_query("UPDATE users SET password='$pass3' WHERE email='$email'");
mysql_query("UPDATE users SET newpw_code='' WHERE email='$email'");
mysql_query("DELETE FROM pw_ask WHERE code='$code'");
header("Location: index.php?ret=pw");
} else {
echo 'Wrong code';
}
}
Only this query got executed:
mysql_query("DELETE FROM pw_ask WHERE code='$code'");
Also when I enter the right code, it says “Wrong code”.
$this="Everything";- Whoever contributes to answering this, shouldn't; period. And if they do, give a reason why. I never contribute to question that use passwords stored in plain text ormd5.mysql_querywhich should not be used in new applications because it's being removed from future versions of PHP. A modern replacement like PDO is not hard to learn. A guide like PHP The Right Way shows how to avoid making these sorts of mistakes.