PDA

View Full Version : Forgotten Password


richclare1991
04-15-2012, 08: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" />
</form>

<?php

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

include("include/connection.php");

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";
}

}
?>

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

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