Forgotten password
Posted: Fri Nov 28, 2003 8:29 am
Ok, my next question is about making a forgotten password page. I have made it and what I want it to do is to take the email they sent in and get the corresponding password for it. My DB info is:
Table: members
3 Rows: id, email, password
Here is my script, tell me what's wrong please:
if ($submit) {
mysql_connect("localhost","username","password") or die ("Unable to connect to MySQL server.");
$db = mysql_select_db("DB name") or die ("Unable to select requested database.");
$sql_email_check = mysql_query("SELECT password FROM members WHERE email='$email'");
$password = mysql_num_rows($sql_email_check);
if ($email == ""){
echo '<p align="center">Sorry, the form was left blank!</p>';
} else {
$sql_email_check = mysql_query("SELECT email FROM members WHERE email='$email'");
$email_check = mysql_num_rows($sql_email_check);
if($email_check > 0){
$to = $email;
$subject = "subject";
$message = "We have received your notice of a forgotten password. Here is your password:
Email: $email
Password: $password
If you have any questions/comments, don't hesitate to ask our staff!
Thanks!
This is an automated response, please do not reply!";
mail($to, $subject, $message, "From: dave_young@ameritech.net");
echo '<head><meta http-equiv="refresh" content="1;URL=index.php"></head><b><p>An email has been sent to you containing your password!</b></p><center>';
} else {
echo '<p><font color="#FF0000">That email address is not registered with TidBitFacts.com!</font></p><center>';
}}}
?>
Table: members
3 Rows: id, email, password
Here is my script, tell me what's wrong please:
if ($submit) {
mysql_connect("localhost","username","password") or die ("Unable to connect to MySQL server.");
$db = mysql_select_db("DB name") or die ("Unable to select requested database.");
$sql_email_check = mysql_query("SELECT password FROM members WHERE email='$email'");
$password = mysql_num_rows($sql_email_check);
if ($email == ""){
echo '<p align="center">Sorry, the form was left blank!</p>';
} else {
$sql_email_check = mysql_query("SELECT email FROM members WHERE email='$email'");
$email_check = mysql_num_rows($sql_email_check);
if($email_check > 0){
$to = $email;
$subject = "subject";
$message = "We have received your notice of a forgotten password. Here is your password:
Email: $email
Password: $password
If you have any questions/comments, don't hesitate to ask our staff!
Thanks!
This is an automated response, please do not reply!";
mail($to, $subject, $message, "From: dave_young@ameritech.net");
echo '<head><meta http-equiv="refresh" content="1;URL=index.php"></head><b><p>An email has been sent to you containing your password!</b></p><center>';
} else {
echo '<p><font color="#FF0000">That email address is not registered with TidBitFacts.com!</font></p><center>';
}}}
?>