Hello,
What I am trying to do is make it to where people can either request there password by just an echo for fast results, or send it to there email.
Now, obviously they don't remember there password if they've come to this page, so I won't be asking for it. I will, however, be asking for there email address. What I need to do is set it up to where when they fill out everything correctly it will FETCH the array 'password' from the database according to the email provided. This is my code below.
<?
include 'db.php';
$mail = $_POST ['mail'];
$nomail = $_POST ['nomail'];
$email = $_POST ['email_address'];
$answer2 = $_POST ['answer'];
if((!$mail) && (!$nomail))
{
echo "Please tell us how you would like to receive your password. <br>";
include 'lost_pw.html';
exit();
}
if(!$answer)
{
echo "Please tell us what your secret answer <br>is in order to receive your password. <br>";
include 'lost_pw.html';
exit();
}
$sql_check = mysql_query("SELECT * FROM users WHERE email_address='$email_address'");
$sql_check_num = mysql_num_rows($sql_check);
if($sql_check_num == 0){
echo "No records found matching your email address<br />";
include 'lost_pw.html';
exit();
}
$sql = mysql_query("SELECT * FROM users WHERE answer='$answer'");
$sql2 = mysql_num_rows($sql);
if($answer2 == $sql2)
{
echo "I'm sorry, you did not give the correct answer!<br />";
include 'lost_pw.html';
exit();
}
$sql = mysql_query("SELECT * FROM users WHERE pass='$pass' AND email_address='$email_address'");
$row = mysql_fetch_array($sql);
$password = $row['pass'];
if($mail == 'no')
{
echo "<b>Your password is: <font color=red>$password</font></b> <br>";
include 'login_form.html';
exit();
}
else
{
echo "<strong>Your new password has been sent to your e-mail!</strong><br />";
include 'login_form.html';
$subject = "Your Password for MSP Inc.!";
$message = "Hi, here is your new password.
Password: $random_password
[url]http://www.mysite.com/login_form.html[/url]
Thanks!
The Webmaster
This is an automated response, please do not reply!";
mail($email_address, $subject, $message, "From: MSP Inc.<my email>\nX-Mailer: PHP/" . phpversion());
}
?>
Can anybody find any errors??
Thanks for any help!
-Blake