require("includes.php");
require("admin/login/lang/lang_en.php");
//identify page state
$processForm = FALSE;
$emailSent = FALSE;
if (array_key_exists('submit_check', $_POST)) {
$processForm = TRUE;
}
if ($processForm){
//process the form and do validation
$email = $_POST['email'];
$validationErrors = '';
$errorTrue = 0;
if ($email == ""){
$validationErrors .= "Please enter an email address.
";
$errorTrue = 1;
}
if ($email != ""){
if(!preg_match("/^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,6}$/i", $email)) {
$validationErrors .= "Please enter a valid email address.
";
$errorTrue = 1;
}
}
//username check
$sql = "SELECT password FROM tbl_users WHERE email='$email'";
$query = mysql_query($sql);
$count = mysql_num_rows($query);
if($count == 0) {
$validationErrors .= "This email address was not found.";
$errorTrue = 1;
}
$validationErrors .= "
";
//end validation
if ($errorTrue != 1 AND $count != 0){
//send the email
$row = mysql_fetch_object($query);
$pass = htmlspecialchars($row->password);
$to = $email;
$subject = "Angelisms Password";
$body = "Your password for www.Angelisms.com is $pass";
if (mail($to, $subject, $body)){
$emailSent = TRUE;
}
}
}
else{ //display the form
$processForm = FALSE;
}
?>