Guest User

Untitled

a guest
Aug 8th, 2016
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.28 KB | None | 0 0
  1. <?php
  2.  
  3. $host = 'localhost';
  4. $user_name = 'u891638989_user';
  5. $password = '123456';
  6. $db_name = 'u891638989_data';
  7. $con = mysqli_connect($host,$user_name,$password,$db_name) or die ('Unable to connect');
  8.  
  9.  
  10. require_once 'PHPMailerAutoload.php';
  11. require_once 'DB_Functions2.php';
  12. $db = new DB_Functions2();
  13.  
  14. $forgotpassword = $_POST['email'];
  15.  
  16. $randomcode = $db->random_string();
  17. /*
  18. $subject = "Password Recovery";
  19. $message = "Hello User,nnYour Password is sucessfully changed. Your new Password is $randomcode . Login with your new Password and change it in the User Panel.";
  20. $from = "contact@learn2crack.com";
  21. $headers = "From:" . $from;*/
  22. if ($db->isUserExisted($forgotpassword)) {
  23.  
  24. //$user = $db->forgotPassword($forgotpassword, $encrypted_password, $salt);
  25. $user = $db->forgotPassword($forgotpassword, $randomcode);
  26. if ($user) {
  27. $response["success"] = 1;
  28. $mail = new PHPMailer;
  29.  
  30. //$mail->SMTPDebug = 3; // Enable verbose debug output
  31.  
  32. $mail->isSMTP(); // Set mailer to use SMTP
  33. $mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers
  34. $mail->SMTPAuth = true; // Enable SMTP authentication
  35. $mail->Username = 'user@example.com'; // SMTP username
  36. $mail->Password = 'secret'; // SMTP password
  37. $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
  38. $mail->Port = 587; // TCP port to connect to
  39.  
  40. $mail->setFrom('from@example.com', 'Mailer');
  41. $mail->addAddress('joe@example.net', 'Joe User'); // Add a recipient
  42. $mail->addAddress('ellen@example.com'); // Name is optional
  43. $mail->addReplyTo('info@example.com', 'Information');
  44. $mail->addCC('cc@example.com');
  45. $mail->addBCC('bcc@example.com');
  46.  
  47. $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
  48. $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
  49. $mail->isHTML(true); // Set email format to HTML
  50.  
  51. $mail->Subject = 'Here is the subject';
  52. $mail->Body = 'This is the HTML message body <b>in bold!</b>';
  53. $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  54.  
  55. if(!$mail->send()) {
  56. echo 'Message could not be sent.';
  57. echo 'Mailer Error: ' . $mail->ErrorInfo;
  58. } else {
  59. echo 'Message has been sent';
  60. }
  61. // mail($forgotpassword,$subject,$message,$headers);
  62. // $to = $forgotpassword;
  63. // $subject = "Password Recovery";
  64. // $message = "Hello User,nnYour Password is sucessfully changed. Your new Password is $randomcode . Login with your new Password and change it in the User Panel.";
  65. // $mail->send($to, $subject, $message);
  66. echo json_encode($response);
  67. }
  68. else {
  69. $response["error"] = 1;
  70. echo json_encode($response);
  71. }
  72. }else{
  73. $response["error"] = "fail";
  74. echo json_encode($response);
  75. }
  76.  
  77.  
  78.  
  79.  
  80. mysqli_close($con);
  81.  
  82. ?>
Add Comment
Please, Sign In to add comment