Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. <?php
  2.  
  3. $host="localhost"; // Host name - update all those fields
  4. $username="xxxxx"; // Mysql username
  5. $password="xxxx"; // Mysql password
  6. $db_name="xxxxxx"; // Database name
  7.  
  8. //Connect to server and select databse.
  9. mysql_connect("$host", "$username", "$password")or die("cannot connect to server"); mysql_select_db("$db_name")or die("cannot select DB");
  10.  
  11. // value sent from form
  12. $email_to=$_POST['email_to']; // table name
  13. $tbl_name=tz_members;
  14.  
  15. // retrieve password from table where e-mail is equal
  16. $sql="SELECT usr, pass, regIP FROM $tbl_name WHERE email='$email_to'"; $result=mysql_query($sql);
  17.  
  18. // if found this e-mail address, row must be 1 row // keep value in variable name "$count"
  19. $count=mysql_num_rows($result);
  20.  
  21. // compare if $count =1 row
  22. if($count==1) { $rows=mysql_fetch_array($result);
  23.  
  24. $your_username=$rows['usr']; $your_password=$rows['pass']; $your_ip=$rows['regIP']; $pass = substr(md5($your_ip.microtime().rand(1,100000)),0,6); // create a new pass
  25. mysql_query(" UPDATE tz_members SET pass='".md5($pass)."' WHERE email='".$email_to."'"); // update the db
  26.  
  27. // ---------------- SEND MAIL FORM ---------------- // send e-mail to ...
  28. $to=$email_to;
  29.  
  30. // Your subject
  31. $subject="Your password here";
  32.  
  33. // From
  34. $header="from: your name ";
  35.  
  36. // Your message
  37. $messages= "Your password for login has been reset.rn"; $messages.="The new password is $pass rn"; $messages.="Regards rn";
  38.  
  39. // send email
  40. $sentmail = mail($to,$subject,$messages,$header);
  41.  
  42. mysql_free_result($result); }
  43.  
  44. // else if
  45. $count not equal 1 else if ($count==0) echo "Your email was not found in our database"; else echo "More than one (".$count.") email records was found in our database, please contact the administrator.";
  46.  
  47. // if your email succesfully sent
  48. if($sentmail) { echo "The new password has been reset and sent to the email on record."; } else { echo "Cannot send the password to this e-mail address"; }
  49.  
  50. ?>
  51.  
  52. // else if
  53. $count not equal 1 else if ($count==0) echo "Your email was not found in our database";
  54. else echo "More than one (".$count.") email records was found in our database, please contact the administrator.";
  55.  
  56. // else if $count not equal 1
  57.  
  58. else if ($count==0) echo "Your email was not found in our database";
  59. else echo "More than one (".$count.") email records was found in our database, please contact the administrator.";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement