'; echo "

Password recovery

"; $email_address = $_POST[email_address]; switch($_POST['recover']){ default: echo "

Please enter your email address

"; include 'lost_pw.php'; break; case "recover": recover_pw($email_address); break; } function recover_pw($email_address){ if(!$email_address){ echo "

You forgot to enter your Email address!

"; include 'lost_pw.php'; include 'footer.php'; exit(); } // quick check to see if record exists $sql_check = mysql_query("SELECT * FROM users WHERE email ='$email_address'") or die(mysql_error()); $sql_check_num = mysql_num_rows($sql_check); if($sql_check_num == 0){ echo "

No records found matching your email address!

"; include 'lost_pw.php'; include 'footer.php'; exit(); } // Everything looks ok, generate password, update it and send it! $sql = mysql_query("SELECT * FROM users WHERE email ='$email_address'") or die(mysql_error()); $password_arr = mysql_fetch_array($sql); $password = $password_arr['password']; $subject = "Your Cottages by County password"; $message = " Hi, we have resent your password. Password: $password Thanks! Cottages by County www.cottagesbycounty.com info@cottagesbycounty.com This is an automated response, please do not reply!"; mail($email_address, $subject, $message, "From: Cottages by County\nX-Mailer: PHP/" . phpversion()); echo "

Your password has been sent! Please check your email!

"; } echo '
'; include 'footer.php'; ?>