Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Load Composer's autoloader
- require 'vendor/autoload.php';
- use PHPMailer\PHPMailer\PHPMailer;
- use PHPMailer\PHPMailer\Exception;
- $mail = new PHPMailer(true); // Passing `true` enables exceptions
- try {
- //Server settings
- $mail->SMTPDebug = 0; // Enable verbose debug output
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = 'ur mail'; // SMTP username
- $mail->Password = ' ur pass'; // SMTP password
- $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
- $mail->Port = 587; // TCP port to connect to
- //Recipients
- $mail->setFrom('from@example.com', 'Mailer');
- $mail->addAddress('berkaybedriyilmaz@gmail.com', 'Berkay Yilmaz'); // Add a recipient
- // Connect to MySQL
- $username = "root";
- $password = "";
- $host = "localhost";
- $dbname = "intakesysteem";
- try {
- $conn = new PDO("mysql:host={$host};dbname={$dbname};charset=utf8", $username, $password);
- }
- catch(PDOException $ex)
- {
- $msg = "Failed to connect to the database";
- }
- /// Was the form submitted?
- if (isset($_POST["ForgotPassword"])) {
- // Harvest submitted e-mail address
- if (filter_var($_POST["email"], FILTER_VALIDATE_EMAIL)) {
- $email = $_POST["email"];
- }else{
- echo "email is not valid";
- exit;
- }
- // Check to see if a user exists with this e-mail
- $notfound = "No user with that e-mail address exists.";
- $query = $conn->prepare('SELECT email FROM users WHERE email = :email');
- $query->bindParam(':email', $email);
- $query->execute();
- $userExists = $query->fetch(PDO::FETCH_ASSOC);
- $conn = null;
- if ($userExists["email"]) {
- // Create a unique salt. This will never leave PHP unencrypted.
- $salt = "498#2D83B631%3800EBD!801600D*7E3CC13";
- // Create the unique user password reset key
- $password = hash('sha512', $salt . $userExists["email"]);
- // Create a url which we will direct them to reset their password
- } else
- echo '<body>
- <div class="wrapper centered registerwrapper">
- <img class="centeredimg" src="assets/images/mborijnlandlogo.png">
- <h2 class="text-center registerh2">'.$notfound.'</php></h2>
- <label class="bg-warning"><? echo $notfound;?></label>
- </div>
- </body>';
- }
- $pwrurl = "http://localhost/reset_password.php?q=" . $password;
- $body = "Goeiedag, Als u geen wachtwoord vervanging hebt aan gevraagd, reageer hier dan <b>niet</b> op.<br><br>
- Het lijkt er op dat u een wachtwoord vervanging hebt aangevraagd op <b>http://www.mborijnland.nl</b>.
- <br> Klik op de onderstaande link om uw wachtwoord te vervangen.
- 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>
- Bedankt voor de medewerking,<br> Administratieteam";
- //Content
- $mail->isHTML(true); // Set email format to HTML
- $mail->Subject = 'www.yoursitehere.com - Password Reset';
- $mail->Body = $body;
- $mail->AltBody = strip_tags($body);
- $mail->send();
- } catch (Exception $e) {
- echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
- }
- ?>
- <!DOCTYPE HTML>
- <html lang="nl">
- <head>
- <meta charset="UTF-8">
- <title>Login</title>
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css">
- <link rel="stylesheet" href="assets/css/bootstrap.min.css">
- <link rel="stylesheet" href="assets/css/fontawesome-all.css">
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
- <link rel="stylesheet" href="assets/css/styles.css">
- <style type="text/css">
- body{ font: 14px sans-serif;
- background-position: center;
- background-size: cover;
- }
- .wrapper{ width: 350px; padding: 20px; }
- </style>
- </head>
- <body>
- <div class="wrapper centered registerwrapper">
- <img class="centeredimg" src="assets/images/mborijnlandlogo.png">
- <h2 class="text-center registerh2">De mail is verstuurd</h2>
- <a class="text-center" href="home.php">Keer terug naar de login pagina.</a>
- <label class="bg-warning"><? echo $notfound;?></label>
- </div>
- </body>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement