<?php // Get the directory of the current script $currentDir = __DIR__; $phpMailerDir = 'C:\wamp64\www\obaju\distribution\sendEmails\vendor\phpmailer\phpmailer'; require_once $phpMailerDir . '\src\PHPMailer.php'; require_once $phpMailerDir . '\src\SMTP.php'; require_once $phpMailerDir . '\src\Exception.php'; use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\Exception; // Create a new PHPMailer instance /* Create a new PHPMailer object. Passing TRUE to the constructor enables exceptions. */ $mail = new PHPMailer(TRUE); try { // Server settings $mail->SMTPDebug = SMTP::DEBUG_OFF; $mail->isSMTP(); $mail->Host = 'smtp-mail.outlook.com'; // Enter your SMTP server here $mail->SMTPAuth = true; $mail->Username = "me@there.com"; $mail->Password = "Whatever"; // SMTP password $mail->SMTPSecure = 'tls'; $mail->Port = 587; // Port number depends on your SMTP server configuration // Sender and recipient details $mail->setFrom('gcira2023@outlook.com', 'From eCommerce Store'); $mail->addAddress('entsagcobza2020@gmail.com', 'Recipient Name'); // Email content $mail->isHTML(false); $mail->Subject = 'Password Reset'; $otp = rand(100000, 999999); $mail->Body = 'Your OTP code is: ' . $otp; // Send the email $mail->send(); if (!$mail->send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message sent!"; } } catch (Exception $e) { // Output an error message if the email failed to send echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo; } ?> <!DOCTYPE html> <html> <head> <!-- CSS --> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Obaju : e-commerce template</title> <meta name="description" content=""> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="robots" content="all,follow"> <!-- Bootstrap CSS--> <link rel="stylesheet" href="vendor/bootstrap/css/bootstrap.min.css"> <!-- Font Awesome CSS--> <link rel="stylesheet" href="vendor/font-awesome/css/font-awesome.min.css"> <!-- Google fonts - Roboto --> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,700"> <!-- owl carousel--> <link rel="stylesheet" href="vendor/owl.carousel/assets/owl.carousel.css"> <link rel="stylesheet" href="vendor/owl.carousel/assets/owl.theme.default.css"> <!-- JS --> <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.3/dist/umd/popper.min.js"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> <!-- owl carousel--> </head> <body> <div class="container"> <div class="row justify-content-center"> <div class="col-md-6"> <div class="card mt-5"> <div class="card-header"> Reset Password </div> <div class="card-body"> <form id="forgot-password"> <div class="form-group"> <label for="email">Email</label> <input type="email" class="form-control" id="email" name="email" required> </div> <div class="form-group"> <label for="new-password">New Password</label> <input type="password" class="form-control" id="new-password" name="new-password" required> </div> <div class="form-group"> <label for="confirm-password">Confirm Password</label> <input type="password" class="form-control" id="confirm-password" name="confirm-password" required> </div> <button type="submit" class="btn btn-primary">Reset Password</button> </form> </div> </div> </div> </div> </div> <!-- JavaScript files--> <script src="vendor/jquery/jquery.min.js"></script> <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script> <script src="vendor/jquery.cookie/jquery.cookie.js"> </script> <script src="vendor/owl.carousel/owl.carousel.min.js"></script> <script src="vendor/owl.carousel2.thumbs/owl.carousel2.thumbs.js"></script> <script src="js/front.js"></script> <script src="js/deletion_shopping_cart.js"></script> <script src="js/add_to_cart.js"></script> <script src="js/forgot-password.js"></script> </body> </html>
<pre>$(document).ready(function(){ $("#forgot-password").submit(function(event){ event.preventDefault(); var formData = $(this).serialize(); // console.log($('#forgot-password').serialize()); $.ajax({ url: "forgot-password.php", type: "POST", data: formData, success: function(data){ if(data == "success"){ alert("Password reset successfully."); window.location.href = "dashboard.php"; }else if(data == "error"){ alert("Invalid email or OTP code."); }else if(data == "password_mismatch"){ alert("New password and confirm password do not match."); }else{ alert("Something went wrong. Please try again later."); } } }); }); });
// in JS native : document.getElementById('the_id_selector').value = ""
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)