Advertisement
Guest User

Untitled

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