-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforgotPasswordProcess.php
More file actions
52 lines (41 loc) · 1.52 KB
/
forgotPasswordProcess.php
File metadata and controls
52 lines (41 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
require "includes/connection.php";
require "PHPmail/SMTP.php";
require "PHPmail/PHPMailer.php";
require "PHPmail/Exception.php";
use PHPMailer\PHPMailer\PHPMailer;
if (isset($_GET["e"])) {
$email = $_GET["e"];
$rs = Database::search("SELECT * FROM `user` WHERE `email`='" . $email . "'");
$n = $rs->num_rows;
if ($n == 1) {
$code = uniqid();
Database::iud("UPDATE `user` SET `verification_code`='" . $code . "' WHERE `email`='" . $email . "'");
$mail = new PHPMailer;
$mail->IsSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'anandawijekoon533@gmail.com';
$mail->Password = 'dknmofgemudyxnnq';
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
$mail->setFrom('anandawijekoon533@gmail.com', 'Reset Password');
$mail->addReplyTo('anandawijekoon533@gmail.com', 'Reset Password');
$mail->addAddress($email);
$mail->isHTML(true);
$mail->Subject = 'Play Tech Solutions Forgot Password Verification Code';
// Load HTML content from the file
$htmlContent = file_get_contents('PHPmail/email_template.html');
// Replace placeholder with the actual code
$bodyContent = str_replace('{{code}}', $code, $htmlContent);
$mail->Body = $bodyContent;
if (!$mail->send()) {
echo 'Verification code sending failed';
} else {
echo 'Success';
}
} else {
echo 'Invalid Email address';
}
}
?>