//This is the form used if people forgot their password
include("header.php");
include("config.php");
require('validate.php');
$sqlConnection = mysql_connect(localhost,$username,$password) or die ('Unable to connect to the database because: ' . mysql_error());
@mysql_select_db($database) or die( "Unable to select database");
?>
$email = $_POST['email'];
// If the submit button has been pressed
if (isset($_POST['submit']))
{
//check if email is empty
if ($email == "") {
echo "Please enter your email.
";
exit;
}
//if email is not empty, check if its a valid email
else{
if (!validate_email($_POST['email'])){
//echo "Thank you for registering. You can now login.";
echo "The email address ".$_POST['email']." is invalid. Please go back and enter a valid email address.";
exit();
}
}
//user entered all fields correctly
$query2 = "SELECT * FROM `users` WHERE email='$email'";
$result2 = mysql_query($query2);
//the email is found!
if (mysql_num_rows($result2) > 0){
//echo 'we found your email';
$row= mysql_fetch_assoc($result2);
$question = $row['question'];
$answer = $row['answer'];
$email = $row['email'];
include ("secret.php");
exit();
}
//the email is not found
else{
echo $_POST['email'] . " is not in the database please go back and enter the email address that is in our database.";
exit();
}
}
?>
Please enter your email below: