Guest User

Untitled

a guest
Feb 20th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. <?
  2.  
  3. $host="localhost"; // Host name
  4. $username="kennych_kennych"; // Mysql username
  5. $password="Stu6_4^T(%5i"; // Mysql password
  6. $db_name="kennych_register"; // Database name
  7. $new_password="";
  8.  
  9. //Connect to server and select databse.
  10. mysql_connect("$host", "$username", "$password")or die("cannot connect to server");
  11. mysql_select_db("$db_name")or die("cannot select DB");
  12.  
  13. // value sent from form
  14. $email_to=$_POST['email_to'];
  15.  
  16. // table name
  17. $tbl_name=users;
  18.  
  19.  
  20. // if found this e-mail address, row must be 1 row
  21. // keep value in variable name "$count"
  22. $count=mysql_num_rows($result);
  23.  
  24. // compare if $count =1 row
  25. if($count==1){
  26.  
  27. $rows=mysql_fetch_array($result);
  28.  
  29. // keep password in $your_password
  30. $your_password=$rows['password'];
  31.  
  32. $random_password=md5(uniqid(rand()));
  33. $emailpassword=substr($random_password, 0, 8);
  34. $newpassword = md5($emailpassword);
  35.  
  36.  
  37.  
  38. // ---------------- SEND MAIL FORM ----------------
  39.  
  40. // send e-mail to ...
  41. $to=$email_to;
  42.  
  43. // Your subject
  44. $subject="Your password here";
  45.  
  46. // From
  47. $header="from: your name <your email>";
  48.  
  49. // Your message
  50. $messages= "Your password for login to our website \r\n";
  51. $messages.="Your password is $your_password \r\n";
  52. $messages.="more message... \r\n";
  53.  
  54. // send email
  55. $sentmail = mail($to,$subject,$messages,$header);
  56.  
  57. }
  58.  
  59. // else if $count not equal 1
  60. else {
  61. echo "Not found your email in our database";
  62. }
  63.  
  64. // if your email succesfully sent
  65. if($sentmail){
  66. echo "Your Password Has Been Sent To Your Email Address.";
  67. }
  68. else {
  69. echo "Cannot send password to your e-mail address";
  70. }
  71.  
  72. ?>
Add Comment
Please, Sign In to add comment