Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi, I'm looking for a forgot password script that would work with a existing login script that uses PHP and MYSQL I want members to be able to retrieve forgotten their password by typing their email address or username
in the form, sending a automatically email to them with their password a found similar script, but it keeps giving me error. here is the script
<?php
// MySQL Information.$db_host = "localhost"; // Host, 99% of the time this is localhost.
$db_username = "username"; // Username here
$db_password = "password"; // Password here$linkID = @mysql_connect("$db_host", "$db_username", "$db_password");
// query commands
mysql_select_db("login", $linkID) or die(mysql_error()); // Database here
$resultID = mysql_query("SELECT username FROM signup WHERE email = '$email'", $linkID) or die(mysql_error());// End of query commands
// Check if Email is in database$num_rows = mysql_num_rows($resultID);
$row = mysql_fetch_array($resultID);
$user_id = $row[0];if ($user_id == "") {
print "We're sorry, your Email does not appear to be in our database.";
}
else {
// query commands$resultID = mysql_query("SELECT password FROM signup WHERE email = '$email'", $linkID) or die(mysql_error());
$row = mysql_fetch_array($resultID);
$passwordfromdb = $row[0];// End of query commands
// Send Password to emailmail($email, "Your Password", "Password: $passwordfromdb", "FROM: webmaster@mysite.com");
echo "Your Password has been sent to $email ";}
// End of Send Password to emailmysql_close($linkID);
?>
when I type in a email address I get the following errors
Notice: Undefined variable: email in C:\Program Files\Apache Group\Apache2\htdocs1\signup\forgotpassword.php on line 13
We're sorry, your Email does not appear to be in our database.line: 13 is...
$resultID = mysql_query("SELECT username FROM signup WHERE email = '$email'", $linkID) or die(mysql_error());
what's causing the errors, and even when the email address is stored on the my database it still says it not what's causing the errors, and even when the email address is stored on the my database it still says it not can someone please help me out to get this script to work.

Are you sure that the query is using the $email variable and not sending the literal string of "$email". You can do a quick test by doing the following:
Add these two lines just before line 13:
$queryString = "SELECT username FROM signup WHERE email = '$email'";
echo $queryString . "[br]";Then change line 13 to:
$resultID = mysql_query($queryString, $linkID) or die(mysql_error());
Now you will see exactly what is being sent to MySQL. If the string "$email" is being sent in the query instead of the variable value, you can modify the query as follows:
$queryString = "SELECT username FROM signup WHERE email = '".$email."'";
Michael J

I can't to get it working, it seems like it's not sending anything, am not too good at PHP, do you now any other scripts I can use, or know where I can download them?
I just need a simple to fetch the username
and password from MYSQL database or from
.htaccess and send it to the user by email.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |