Advertisement
Guest User

Untitled

a guest
Oct 4th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. <?php include "connection.php";
  2.  
  3. if(isset($_POST) & !empty($_POST)){
  4. //print_r($_POST); die;
  5. $username = mysqli_real_escape_string($conn, $_POST['username']);
  6. $sql = "SELECT * FROM `users` WHERE username = '$username'";
  7. $res = mysqli_query($conn, $sql);
  8. $count = mysqli_num_rows($res);
  9. if($count == 1){
  10. echo "Send email to user with password";
  11. }else{
  12. echo "User name does not exist in database";
  13. }
  14.  
  15. $r = mysqli_fetch_assoc($res);
  16. $password = $r['password'];
  17. $to = $r['username'];
  18. $subject = "Your Recovered Password";
  19.  
  20. $message = "Please use this password to login " . $password;
  21. $headers = "From :abc23@gmail.com";
  22. if(mail($to, $subject, $message, $headers)){
  23. echo "Your Password has been sent to your email id";
  24. }else{
  25. echo "Failed to Recover your password, try again";
  26.  
  27. }
  28.  
  29. }
  30.  
  31.  
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement