Advertisement
Guest User

Untitled

a guest
May 26th, 2017
561
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1.  
  2.  
  3. function invio_email_psw()
  4. {
  5. global $con;
  6. $email = $con->real_escape_string($_POST['email']);
  7. $query = "SELECT * FROM admin WHERE email = '$email'";
  8. // Perform queries and print out affected rows
  9. if ($ris = $con->query($query)) {
  10. /* fetch associative array */
  11.  
  12. if (mysqli_affected_rows($con) > 0) {
  13. $row = $ris->fetch_assoc();
  14. $ID = $row['ID'];
  15. $hash = $row['pass'] . "" . $row['ID'];
  16. require 'PHPMailer-master/PHPMailerAutoload.php';
  17. $mail = new PHPMailer;
  18. $mail->isSMTP();
  19. $mail->SMTPDebug = 2;
  20. $mail->Debugoutput = 'html';
  21. $mail->Host = 'smtp.gmail.com';
  22. $mail->Port = 587;
  23. $mail->SMTPSecure = 'tls';
  24. $mail->SMTPAuth = true;
  25. $mail->Username = "r.readellavolpe@gmail.com";
  26. $mail->setFrom('r.readellavolpe@gmail.com', 'First Last');
  27. $mail->addReplyTo('r.readellavolpe@gmail.com', 'First Last');
  28. $mail->addAddress('r.readellavolpe@gmail.com', 'John Doe');
  29. $mail->Subject = 'Reimposta la password di MyLIFE';
  30. $mail->Body = 'Abbiamo ricevuto la richiesta di reimpostare la password del tuo account ' . $email . ' <br> Fai Click sul link:
  31. <a href="localhost/login/login-ajax/reimposta_psw.php?id=' . $ID . '&code=' . $hash . '">LINK</a> per impostare una nuova password.';
  32. $mail->AltBody = 'This is a plain-text message body';
  33. if($mail->send()){
  34. $response_array['status'] = 'success';
  35. }
  36. }
  37.  
  38.  
  39. else{
  40.  
  41. $response_array['status'] = 'error';
  42.  
  43. }
  44.  
  45. }
  46. echo json_encode($response_array);
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement