cryptonim Posted February 4, 2011 Share Posted February 4, 2011 hi i have a problem with the code to remind the user's password if their forget, the user enter their email address and get them on the mailbox, everything works, but in a place where it should be the password is blank. Help please here's the code: <? include 'db.php'; // Conver to simple variables switch($_POST['recover']){ default: include 'lost_pw.html'; break; case "recover": recover_pw($_POST['email_address']); break; } function recover_pw($email_address){ if(!$email_address){ echo "You forgot to enter your Email address !!<br />"; include 'lost_pw.html'; exit(); } // quick check to see if record exists $sql_check = mysql_query("SELECT * FROM users WHERE email_address='$email_address'"); $sql_check_num = mysql_num_rows($sql_check); if($sql_check_num == 0){ echo "No records found matching your email address<br />"; include 'lost_pw.html'; exit(); } // Everything looks ok, generate password, update it and send it! $db_password = md5 ($password); $to = "email"; $sql = mysql_query("UPDATE users SET password='$password_md5' WHERE email_address='$email_address'"); $headers = "From: mymail@02.com"; $subject = "Your Password at MyWebsite!"; $message = "Hi $username your username and password is, Username:$username Password:$password http://www.something.com/login_form.html Thanks! The Webmaster This is an automated response, please do not reply!"; mail($email_address, $subject, $message, "From: M@m.com>\nX-Mailer: PHP/" . phpversion()); include 'password.html'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/226670-trouble-with-code-to-remind-password/ Share on other sites More sharing options...
sasa Posted February 4, 2011 Share Posted February 4, 2011 you must generate new pasword before insert it in database Quote Link to comment https://forums.phpfreaks.com/topic/226670-trouble-with-code-to-remind-password/#findComment-1169826 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.