MrXortex Posted August 2, 2013 Share Posted August 2, 2013 Hello. I created a little recover page. Users write the email and a random password is sent to them. The random password is successfully send in their emails but when they login with the new password it doesn't login. I think the new password does not updates in my database. How do I fix this issue? Heres the code: (avandare or avandaramn means 'users' in swedish if(isset($_POST['submit']) && $inLoggad == false){ //storing the posted info in variables $email = mysql_real_escape_string($_POST['email']); $exist = mysql_fetch_array( mysql_query("SELECT * FROM anvandare WHERE email='$email' LIMIT 1") ); if($exist['email'] == $email){ //creating a new generated password for the user, if the user has forgotten $newPwd = genPassword(); $newHashPwd = md5($newPwd); //send the new generated password via email of the user $message = "Hello " . $exist['anvandarnamn'] . ". Your new password is: " . $newPwd; $mailheader = "From: HighPload"; $mailheader .= "Reply-To: noreply@noreply.com"; $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; mail($exist['email'], "HighPload - Your new password has arrived!", $message, $mailheader) or die($fail = true); //Updating the new password in the dB if($fail != true){ mysql_query("UPDATE anvandare SET password='$newHashPwd' WHERE email='$email' "); } }else { $showErrors = true; } } elseif($inLoggad == true) { print '<script>window.location = "index.php"</script>'; } ?> Thanks Quote Link to comment Share on other sites More sharing options...
MrXortex Posted August 2, 2013 Author Share Posted August 2, 2013 Anyone? come on? Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted August 2, 2013 Share Posted August 2, 2013 what do you meen "you think"? have you not tested this to find out? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.