Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Get Access to data base
- // Only process POST reqeusts.
- if ($_SERVER["REQUEST_METHOD"] == "POST") {
- // Get the form fields and remove whitespace.
- $email = $_POST["email"];
- // Check that data was sent to the mailer.
- if ( empty($email) ) {
- // Set a 400 (bad request) response code and exit.
- http_response_code(100);
- echo "BLABLABLA.";
- exit;
- }
- if ( !filter_var($email, FILTER_VALIDATE_EMAIL) ) {
- // Set a 400 (bad request) response code and exit.
- http_response_code(200);
- echo "BLABLABLA.";
- exit;
- }
- if (@mysql_num_rows(mysql_query("SELECT `id` FROM `accounts` WHERE `email`='$email'")) < 1) {
- // Set a 400 (bad request) response code and exit.
- http_response_code(300);
- echo "BLABLABLA.";
- exit;
- }
- $row_user = @mysql_fetch_array(mysql_query("SELECT * FROM `accounts` WHERE `email`='$email'"));
- ////////////////////////////
- $password = $row_user['pass'];
- $to = $row_user['email'];
- $subject = "Your Recovered Password";
- $message = "Please use this password to login: " . $password;
- $headers = "From : XXX@XXX.XXX";
- // Send the email.
- if (mail($to, $subject, $message, $headers)) {
- // Set a 200 (okay) response code.
- http_response_code(400);
- echo "BLABLABLA.";
- } else {
- // Set a 500 (internal server error) response code.
- http_response_code(500);
- echo "BLABLABLA.";
- }
- } else {
- // Not a POST request, set a 403 (forbidden) response code.
- http_response_code(600);
- echo "There was a problem with your submission, please try again.";
- }
- ?>
Add Comment
Please, Sign In to add comment