"; if(isset($_POST['reset-pw'])){ $email = $_POST['email']; $pw = generateRandomString(); $r = $conn->query("UPDATE users SET password = '$pw' WHERE email = '$email'"); if(!$r) $status = [ 'msg' => 'Unexpected error occured', 'class' => 'alert-danger' ]; else{ $mail = new PHPMailer(true); //Server settings //$mail->SMTPDebug = SMTP::DEBUG_SERVER; // Enable verbose debug output $mail->isSMTP(); // Send using SMTP $mail->Host = 'smtp.hostinger.com'; // Set the SMTP server to send through $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = 'info@banzararestaurant.in'; // SMTP username $mail->Password = 'Info@123'; // SMTP password $mail->SMTPSecure = 'SSL'; // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` also accepted //$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` also accepted $mail->Port = 587; // TCP port to connect to //Recipients $mail->setFrom('info@banzararestaurant.in', 'Hostinger'); $mail->addAddress($email); // Add a recipient // Content $mail->isHTML(true); // Set email format to HTML $mail->Subject = 'Reset password - Banzararestaurant'; $mail->Body = 'Your new password is '. $pw; if($mail->send()) $status = [ 'msg' => 'New password sent to your email', 'class' => 'alert-success' ]; else $status = [ 'msg' => 'Unexpected error occured', 'class' => 'alert-danger' ]; } } ?>

Reset Password