Advertisement
Guest User

Untitled

a guest
Jun 21st, 2018
554
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.70 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 = 'berkaybedriyilmaz@gmail.com'; // SMTP username
  16. $mail->Password = 'dqkvlxtykwxxsfpp'; // 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.  
  26. $username = "root";
  27.  
  28. $password = "";
  29.  
  30. $host = "localhost";
  31.  
  32. $dbname = "intakesysteem";
  33.  
  34. try {
  35.  
  36. $conn = new PDO("mysql:host={$host};dbname={$dbname};charset=utf8", $username, $password);
  37.  
  38. }
  39.  
  40. catch(PDOException $ex)
  41.  
  42. {
  43.  
  44. $msg = "Failed to connect to the database";
  45.  
  46. }
  47.  
  48.  
  49.  
  50. // Was the form submitted?
  51.  
  52. if (isset($_POST["ForgotPassword"])) {
  53.  
  54.  
  55. // Harvest submitted e-mail address
  56.  
  57. if (filter_var($_POST["email"], FILTER_VALIDATE_EMAIL)) {
  58.  
  59. $email = $_POST["email"];
  60.  
  61.  
  62. } else {
  63.  
  64. echo "email is not valid";
  65.  
  66. exit;
  67.  
  68. }
  69.  
  70.  
  71. // Check to see if a user exists with this e-mail
  72.  
  73. $notfound = "No user with that e-mail address exists.";
  74.  
  75. $query = $conn->prepare('SELECT email FROM users WHERE email = :email');
  76.  
  77. $query->bindParam(':email', $email);
  78.  
  79. $query->execute();
  80.  
  81. $userExists = $query->fetch(PDO::FETCH_ASSOC);
  82.  
  83. $conn = null;
  84.  
  85.  
  86. if ($userExists["email"]) {
  87.  
  88. // Create a unique salt. This will never leave PHP unencrypted.
  89.  
  90. $salt = "498#2D83B631%3800EBD!801600D*7E3CC13";
  91.  
  92.  
  93. // Create the unique user password reset key
  94.  
  95. $password = hash('sha512', $salt . $userExists["email"]);
  96.  
  97.  
  98. // Create a url which we will direct them to reset their password
  99.  
  100.  
  101. } else
  102.  
  103.  
  104. echo $notfound;
  105. }
  106.  
  107.  
  108. $pwrurl = "/reset_password.php?q=" . $password;
  109.  
  110. $body = "Goeiedag, Als u geen wachtwoord vervanging hebt aan gevraagd, reageer hier dan <b>niet</b> op.<br><br>
  111. Het lijkt er op dat u een wachtwoord vervanging hebt aangevraagd op <b>http://www.mborijnland.nl</b>.
  112. <br> Klik op de onderstaande link om uw wachtwoord te vervangen.
  113. 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>
  114. Bedankt voor de medewerking,<br> Administratieteam";
  115.  
  116. //Content
  117. $mail->isHTML(true); // Set email format to HTML
  118. $mail->Subject = 'www.yoursitehere.com - Password Reset';
  119. $mail->Body = $body;
  120. $mail->AltBody = strip_tags($body);
  121.  
  122. $mail->send();
  123. } catch (Exception $e) {
  124. echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
  125. }
  126.  
  127. ?>
  128. <!DOCTYPE HTML>
  129. <html lang="nl">
  130. <head>
  131. <meta charset="UTF-8">
  132. <title>Login</title>
  133. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css">
  134. <link rel="stylesheet" href="assets/css/bootstrap.min.css">
  135. <link rel="stylesheet" href="assets/css/fontawesome-all.css">
  136. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  137.  
  138.  
  139.  
  140. <link rel="stylesheet" href="assets/css/styles.css">
  141. <style type="text/css">
  142. body{ font: 14px sans-serif;
  143. background-position: center;
  144. background-size: cover;
  145. }
  146. .wrapper{ width: 350px; padding: 20px; }
  147. </style>
  148. </head>
  149. <body>
  150. <body>
  151. <div class="wrapper centered registerwrapper">
  152. <img class="centeredimg" src="assets/images/mborijnlandlogo.png">
  153. <h2 class="text-center registerh2">Wachtwoord vergeten</h2>
  154. <label class="bg-success"><? echo $notfound;?></label>
  155. </div>
  156. </body>
  157. </body>
  158. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement