-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforgetPasswordProcess.php
More file actions
83 lines (71 loc) · 4.46 KB
/
forgetPasswordProcess.php
File metadata and controls
83 lines (71 loc) · 4.46 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
include "connection.php";
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
require 'Exception.php';
require 'PHPMailer.php';
require 'SMTP.php';
$email = $_POST["fe"];
$vcode = uniqid();
$rs = Database::search("SELECT * FROM `user` WHERE `email` = '" . $email . "'");
$num = $rs->num_rows;
if ($num > 0) {
Database::iud("UPDATE `user` SET `v_code` = '" . $vcode . "' WHERE `email` = '" . $email . "'");
$mail = new PHPMailer(true);
try {
$mail->isSMTP(); //Send using SMTP
$mail->Host = 'smtp.gmail.com'; //Set the SMTP server to send through
$mail->SMTPAuth = true; //Enable SMTP authentication
$mail->Username = 'pramudithalakshan00@gmail.com'; //SMTP username
$mail->Password = 'luvnppfstwyxxyzz'; //SMTP password
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption
$mail->Port = 465; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
//Recipients
$mail->setFrom('pramudithalakshan00@gmail.com', 'FruitVista');
$mail->addAddress($email); //Add a recipient
$mail->addReplyTo('info@example.com', 'Information');
//Content
$mail->isHTML(true); //Set email format to HTML
$mail->Subject = 'Reset your account password';
$mail->Body = '<table style="width: 100%; font-family: Arial, sans-serif; background-color: #f4f4f4; padding: 20px;">
<tbody>
<tr>
<td align="center">
<table style="max-width: 600px; width: 100%; background-color: #ffffff; border-radius: 10px; box-shadow: 0 4px 8px rgba(0,0,0,0.1); padding: 40px; margin: 20px 0;">
<tr>
<td align="center" style="padding-bottom: 20px;">
<a href="#" style="font-size: 35px; font-weight: bold; color: #333; text-decoration: none;">FruitVista</a>
</td>
</tr>
<tr>
<td style="text-align: center;">
<h1 style="font-size: 25px; line-height: 1.5; font-weight: 600; color: #333;">Reset Password</h1>
<p style="margin-bottom: 24px; color: #666;">You can change your password by clicking on the button below</p>
<div style="margin: 20px 0;">
<a href="http://localhost/FruitVista/resetPassword.php?vcode='.$vcode.'" style="text-decoration: none; display: inline-block; background-color: #007bff; color: #ffffff; padding: 12px 24px; border-radius: 5px; font-size: 16px;">
<span>Reset Password</span>
</a>
</div>
<p style="color: #999;">If you did not request a password reset, please ignore this email.</p>
</td>
</tr>
<tr>
<td align="center" style="padding-top: 20px;">
<p style="color: #666; font-size: 14px;">© 2024 FruitVista</p>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>';
$mail->send();
echo 'Success';
} catch (Exception $email) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
} else {
echo "User not found! Please check your email again";
}
?>