Advertisement
Guest User

Untitled

a guest
Aug 6th, 2017
528
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. <?php
  2.  
  3. if (array_key_exists('forgot',$_POST)) {
  4.  
  5. $email = $_POST['email'];
  6.  
  7. mysql_select_db($database_speedycms, $speedycms);
  8. $query_email = "SELECT * FROM tbl_users WHERE email='$email'";
  9. $email = mysql_query($query_email, $speedycms) or die(mysql_error());
  10. $row_email = mysql_fetch_assoc($email);
  11. $totalRows_user = mysql_num_rows($email);
  12.  
  13. mysql_query("SELECT * FROM users WHERE email='$email'");
  14.  
  15. if($totalRows_user == 0)
  16.  
  17. {
  18. echo "<span class='form2'>We're sorry, but we could not find a user with that email address.<p>Please try again.<p>
  19. <a href='forgotpassword.php' class='form'>Return</a></span>";
  20. }
  21.  
  22. else
  23.  
  24. {
  25.  
  26.  
  27. // create a random password
  28. function createRandomPassword() {
  29. $chars = "abcdefghijkmnopqrstuvwxyz023456789";
  30. srand((double)microtime()*1000000);
  31. $i = 0;
  32. $pass = '' ;
  33. while ($i <= 7) {
  34. $num = rand() % 33;
  35. $tmp = substr($chars, $num, 1);
  36. $pass = $pass . $tmp;
  37. $i++;
  38. }
  39. return $pass;
  40. }
  41. $password = createRandomPassword();
  42.  
  43.  
  44. // generate email
  45.  
  46. $username = $row_email['username'];
  47. $msg = "Your new login information is:nn";
  48. $msg .= "Username: $usernamen";
  49. $msg .= "Password: $passwordn";
  50.  
  51. mail("$email", "Speedy CMS Login Information", "$msg", "From:noreply@domain.com");
  52.  
  53. // display message
  54.  
  55. echo "<span class='form2'>Thanks. Your new password has been sent to <i>".$row_email['email']."</i>.<p>
  56. <a href='index.php' class='form'>Return</a></span>";
  57.  
  58. }
  59.  
  60. exit;
  61.  
  62. }
  63.  
  64. ?>
  65.  
  66. ini_set('SMTP', "server.com");
  67. ini_set('smtp_port', "25");
  68. ini_set('sendmail_from', "email@domain.com");
  69.  
  70. SMTP = smtp.yourdomain.com
  71. smtp_port = 25
  72. username = info@yourdomain.com
  73. password = yourmailpassord
  74. sendmail_from = info@yourdomain.com
  75.  
  76. [mail function]
  77. SMTP = mail.yourdomain.com
  78. smtp_port = 25
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement