Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2018
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.87 KB | None | 0 0
  1. <?php
  2.  
  3. //Load Composer's autoloader
  4. require 'vendor/autoload.php';
  5. use PHPMailer\PHPMailer\PHPMailer;
  6. use PHPMailer\PHPMailer\Exception;
  7.  
  8. $mail = new PHPMailer(true); // Passing `true` enables exceptions
  9. try {
  10. //Server settings
  11. $mail->SMTPDebug = 0; // Enable verbose debug output
  12. $mail->isSMTP(); // Set mailer to use SMTP
  13. $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
  14. $mail->SMTPAuth = true; // Enable SMTP authentication
  15. $mail->Username = 'ur mail'; // SMTP username
  16. $mail->Password = ' ur pass'; // SMTP password
  17. $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
  18. $mail->Port = 587; // TCP port to connect to
  19.  
  20. //Recipients
  21. $mail->setFrom('from@example.com', 'Mailer');
  22. $mail->addAddress('berkaybedriyilmaz@gmail.com', 'Berkay Yilmaz'); // Add a recipient
  23.  
  24. // Connect to MySQL
  25. $username = "root";
  26. $password = "";
  27. $host = "localhost";
  28. $dbname = "intakesysteem";
  29. try {
  30. $conn = new PDO("mysql:host={$host};dbname={$dbname};charset=utf8", $username, $password);
  31. }
  32. catch(PDOException $ex)
  33. {
  34. $msg = "Failed to connect to the database";
  35. }
  36.  
  37. /// Was the form submitted?
  38. if (isset($_POST["ForgotPassword"])) {
  39.  
  40. // Harvest submitted e-mail address
  41. if (filter_var($_POST["email"], FILTER_VALIDATE_EMAIL)) {
  42. $email = $_POST["email"];
  43.  
  44. }else{
  45. echo "email is not valid";
  46. exit;
  47. }
  48.  
  49.  
  50. // Check to see if a user exists with this e-mail
  51.  
  52. $notfound = "No user with that e-mail address exists.";
  53.  
  54. $query = $conn->prepare('SELECT email FROM users WHERE email = :email');
  55.  
  56. $query->bindParam(':email', $email);
  57.  
  58. $query->execute();
  59.  
  60. $userExists = $query->fetch(PDO::FETCH_ASSOC);
  61.  
  62. $conn = null;
  63.  
  64.  
  65. if ($userExists["email"]) {
  66.  
  67. // Create a unique salt. This will never leave PHP unencrypted.
  68.  
  69. $salt = "498#2D83B631%3800EBD!801600D*7E3CC13";
  70.  
  71.  
  72. // Create the unique user password reset key
  73.  
  74. $password = hash('sha512', $salt . $userExists["email"]);
  75.  
  76.  
  77. // Create a url which we will direct them to reset their password
  78.  
  79.  
  80. } else
  81.  
  82.  
  83. echo '<body>
  84. <div class="wrapper centered registerwrapper">
  85. <img class="centeredimg" src="assets/images/mborijnlandlogo.png">
  86. <h2 class="text-center registerh2">'.$notfound.'</php></h2>
  87. <label class="bg-warning"><? echo $notfound;?></label>
  88. </div>
  89. </body>';
  90. }
  91.  
  92.  
  93. $pwrurl = "http://localhost/reset_password.php?q=" . $password;
  94.  
  95. $body = "Goeiedag, Als u geen wachtwoord vervanging hebt aan gevraagd, reageer hier dan <b>niet</b> op.<br><br>
  96. Het lijkt er op dat u een wachtwoord vervanging hebt aangevraagd op <b>http://www.mborijnland.nl</b>.
  97. <br> Klik op de onderstaande link om uw wachtwoord te vervangen.
  98. Als u niet op de link kan klikken verzoeken wij u om het te kopieren en in uw browser te plakken." .'<br><br><b>' . $pwrurl . " </b><br><br>
  99. Bedankt voor de medewerking,<br> Administratieteam";
  100.  
  101. //Content
  102. $mail->isHTML(true); // Set email format to HTML
  103. $mail->Subject = 'www.yoursitehere.com - Password Reset';
  104. $mail->Body = $body;
  105. $mail->AltBody = strip_tags($body);
  106.  
  107. $mail->send();
  108. } catch (Exception $e) {
  109. echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
  110. }
  111.  
  112. ?>
  113. <!DOCTYPE HTML>
  114. <html lang="nl">
  115. <head>
  116. <meta charset="UTF-8">
  117. <title>Login</title>
  118. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css">
  119. <link rel="stylesheet" href="assets/css/bootstrap.min.css">
  120. <link rel="stylesheet" href="assets/css/fontawesome-all.css">
  121. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  122.  
  123.  
  124.  
  125. <link rel="stylesheet" href="assets/css/styles.css">
  126. <style type="text/css">
  127. body{ font: 14px sans-serif;
  128. background-position: center;
  129. background-size: cover;
  130. }
  131. .wrapper{ width: 350px; padding: 20px; }
  132. </style>
  133. </head>
  134. <body>
  135. <div class="wrapper centered registerwrapper">
  136. <img class="centeredimg" src="assets/images/mborijnlandlogo.png">
  137. <h2 class="text-center registerh2">De mail is verstuurd</h2>
  138. <a class="text-center" href="home.php">Keer terug naar de login pagina.</a>
  139. <label class="bg-warning"><? echo $notfound;?></label>
  140. </div>
  141. </body>
  142. </body>
  143. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement