Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php include "connection.php";
- if(isset($_POST) & !empty($_POST)){
- //print_r($_POST); die;
- $username = mysqli_real_escape_string($conn, $_POST['username']);
- $sql = "SELECT * FROM `users` WHERE username = '$username'";
- $res = mysqli_query($conn, $sql);
- $count = mysqli_num_rows($res);
- if($count == 1){
- echo "Send email to user with password";
- }else{
- echo "User name does not exist in database";
- }
- $r = mysqli_fetch_assoc($res);
- $password = $r['password'];
- $to = $r['username'];
- $subject = "Your Recovered Password";
- $message = "Please use this password to login " . $password;
- $headers = "From :abc23@gmail.com";
- if(mail($to, $subject, $message, $headers)){
- echo "Your Password has been sent to your email id";
- }else{
- echo "Failed to Recover your password, try again";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement