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>';
}}}
?>
Forgotten password
Moderator: General Moderators
-
Wldrumstcs
- Forum Commoner
- Posts: 98
- Joined: Wed Nov 26, 2003 8:41 pm
It's because you do not send the password to user. Instead you send count of users with the particular email:
Code: Select all
//....skipped
$password = mysql_num_rows($sql_email_check);
//....skipped
"
....
Password: $password
....
"-
Wldrumstcs
- Forum Commoner
- Posts: 98
- Joined: Wed Nov 26, 2003 8:41 pm
No, I told you what was wrong with your script
Code: Select all
//...skipped
list($password) = mysql_fetch_row($sql_email_check);
//....skipped