Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. // Strona na której podaje sie maila
  2.  
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>System logowania</title>
  6. </head>
  7. <?php
  8.  
  9.  
  10. use PHPMailer\PHPMailer\PHPMailer;
  11. use PHPMailer\PHPMailer\Exception;
  12.  
  13. require 'PHPMailer/src/Exception.php';
  14. require 'PHPMailer/src/PHPMailer.php';
  15. require 'PHPMailer/src/SMTP.php';
  16. require "config.php";
  17.  
  18.  
  19. if(isset($_POST['email']))
  20. {
  21.  
  22. $emailTo = $_POST['email'];
  23.  
  24. $code = uniqid(true);
  25. $query = mysqli_query($con, "INSERT INTO resetPassword(code, email) VALUES('$code', '$emailTo')");
  26. if(!query) {
  27. exit("Error");
  28.  
  29. }
  30.  
  31.  
  32. $mail = new PHPMailer(true);
  33.  
  34. try {
  35. $mail->isSMTP();
  36. $mail->Host = 'mail.CBA.pl';
  37. $mail->SMTPAuth = true;
  38. $mail->Username = 'BOK@ic-dev.cba.pl';
  39. $mail->Password = 'Moje hasło :)';
  40. $mail->SMTPSecure = 'tls';
  41. $mail->Port = 587;
  42.  
  43. //Recipients
  44. $mail->setFrom('BOK@ic-dev.cba.pl', 'IC-DEV.PL');
  45. $mail->addAddress("$emailTo");
  46. $mail->addReplyTo('no-reply@ic-dev.cba.pl', 'no reply');
  47.  
  48.  
  49.  
  50. // Content
  51. $url = "http://" . $_SERVER["HTTP_HOST"] . dirname($_SERVER["PHP_SELF"]) . "/resetPassword.php?code=$code";
  52. $mail->isHTML(true);
  53. $mail->Subject = 'IC-DEV RESET HASŁA';
  54. $mail->Body = "<h1> Aby zmienic haslo kliknij w link ponizej </h1>
  55. <a href='$url'> Zmiana hasla </a>";
  56. $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  57.  
  58. $mail->send();
  59. echo 'Wiadomość została wysłana!';
  60. } catch (Exception $e) {
  61. echo "Wiadomość nie została wysłana. Mailer Error: {$mail->ErrorInfo}";
  62. }
  63.  
  64. }
  65.  
  66. ?>
  67.  
  68. <form method="POST">
  69.  
  70. <input type="text" name="email" placeholder="E-Mail" autocomplete="off"> <br /> <br />
  71. <input type="submit" name="submit" value="Reset password">
  72.  
  73.  
  74.  
  75.  
  76.  
  77. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement