We Recommend

Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems
Wicked Cool PHP contains a wide variety of scripts to process credit cards, check the validity of email addresses, template HTML, and serve dynamic images and text.


Posted By

tylerhall on 07/10/06


Tagged

auth textmate password forgot


Versions (?)


Who likes this?

9 people have marked this snippet as a favorite

kgosser
millisami
irdial
simpeligent
vali29
benrasmusen
Nix
tikitakfire
salibaray


Forgot password logic


Published in: PHP 


  1. $alert = "";
  2. if(isset($_POST['btnsubmit']) && $_POST['email'] != "")
  3. {
  4. $email = mysql_real_escape_string($_POST['email'], $db->db);
  5. $db->query("SELECT username, password FROM users WHERE email = '$email'");
  6. if(mysql_num_rows($db->result) == 0)
  7. $alert = "<div class='alert'>We're sorry, but we could not find a user with that email address.</div>";
  8. else
  9. {
  10. $alert = "<div class='alert'>Your username and password have been emailed to you.</div>";
  11. $row = mysql_fetch_array($db->result, MYSQL_ASSOC);
  12. $username = $row['username'];
  13. $password = $row['password'];
  14. $msg = "Your login information is:\n\n";
  15. $msg .= "Username: $username\n";
  16. $msg .= "Password: $password\n";
  17. mail($email, "Login Information", $msg, "From:noreply@domain.com");
  18. }
  19. }

Report this snippet 

Comments

RSS Icon Subscribe to comments
Posted By: emuman on January 30, 2008

password stored as clear text?

You need to login to post a comment.