Guest User

Untitled

a guest
Jul 29th, 2018
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. <?php
  2.  
  3. // Only process POST reqeusts.
  4. if ($_SERVER["REQUEST_METHOD"] == "POST") {
  5. // Get the form fields and remove whitespace.
  6. $email = $_POST["email"];
  7.  
  8.  
  9. // Check that data was sent to the mailer.
  10. if ( empty($email) ) {
  11. // Set a 400 (bad request) response code and exit.
  12. http_response_code(100);
  13. echo "BLABLABLA.";
  14. exit;
  15. }
  16.  
  17. if ( !filter_var($email, FILTER_VALIDATE_EMAIL) ) {
  18. // Set a 400 (bad request) response code and exit.
  19. http_response_code(200);
  20. echo "BLABLABLA.";
  21. exit;
  22. }
  23.  
  24. if (@mysql_num_rows(mysql_query("SELECT `id` FROM `accounts` WHERE `email`='$email'")) < 1) {
  25. // Set a 400 (bad request) response code and exit.
  26. http_response_code(300);
  27. echo "BLABLABLA.";
  28. exit;
  29. }
  30.  
  31. $row_user = @mysql_fetch_array(mysql_query("SELECT * FROM `accounts` WHERE `email`='$email'"));
  32. ////////////////////////////
  33. $password = $row_user['pass'];
  34. $to = $row_user['email'];
  35. $subject = "Your Recovered Password";
  36. $message = "Please use this password to login: " . $password;
  37. $headers = "From : XXX@XXX.XXX";
  38.  
  39.  
  40. // Send the email.
  41. if (mail($to, $subject, $message, $headers)) {
  42. // Set a 200 (okay) response code.
  43. http_response_code(400);
  44. echo "BLABLABLA.";
  45. } else {
  46. // Set a 500 (internal server error) response code.
  47. http_response_code(500);
  48. echo "BLABLABLA.";
  49. }
  50.  
  51. } else {
  52. // Not a POST request, set a 403 (forbidden) response code.
  53. http_response_code(600);
  54. echo "There was a problem with your submission, please try again.";
  55. }
Add Comment
Please, Sign In to add comment