View Full Version : Forgotten Password

04-15-2012, 07:58 PM
Hi guy's first post try not to slate me too much. Trying to work on a forgotten password feature on a site where the user supplies the email address and then a new random password is sent to the user for them to log in with which they can then edit. It says the email has been sent but when i check my email nothing is there.
Any ideas guys much appreciated?

Heres the code for the page.

<form action="forgottenpasswordform.php" method="POST">

Your Email: <br /> <input type ="text" name="email /> <br />
<input type ="submit" name="submit" value="submit" />


$email = @$_POST ['email'];
$submit = @$_POST ['submit'];


if ($submit) {
$email_check = mysql_query ("SELECT * FROM members WHERE email = '".$email."'");
$count = mysql_num_rows($email_check);

if ($count != 0) {
//generate a new password
$random = rand(72952, 92729);
$new_password = $random;

$email_password = $new_password;

$new_password = md5 ($new_password);

mysql_query("update members set password = '".$new_password."' WHERE email ='".$email."'");

$subject = "Login information";
$message = "Your Password has been changed to $email_password";
$from = "From: example@example.com";

mail ($email, $subject, $message, $from);
echo "Your new password has been emailed to you.";

else {
echo "This email does not exist";


04-16-2012, 01:17 AM
echo $email.$subject. $message.$from; to check the values

04-16-2012, 12:10 PM
Yeah thank you ive managed to get it working :)