Guest User

Untitled

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