-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforgotPasswordProcess.php
More file actions
206 lines (153 loc) · 4.74 KB
/
forgotPasswordProcess.php
File metadata and controls
206 lines (153 loc) · 4.74 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<?php
include "connection.php";
include "Exception.php";
include "PHPMailer.php";
include "SMTP.php";
use PHPMailer\PHPMailer\PHPMailer;
if (isset($_GET["e"])) {
$email = $_GET["e"];
// echo($email);
if (empty($email)) {
echo ("Please Enter Your email Address");
} else {
$user_rs = Database::search("SELECT * FROM `users` WHERE `email` = '" . $email . "' ");
$user_num = $user_rs->num_rows;
if ($user_num == 1) {
// $code = uniqid();
// Database::iud("UPDATE `users` SET `vcode` = '".$code."' WHERE `email` = '".$email."'");
$d = new DateTime();
$tz = new DateTimeZone("Asia/Colombo");
$d->setTimezone($tz);
$date = $d->format("Y-m-d H-i-s");
$status = 1;
$caracters = "0123456789";
$code = '';
for ($x = 0; $x < 4; $x++) {
$code .= $caracters[rand(0, strlen($caracters - 1))]; //generate random integer value min and max value
}
Database::iud("UPDATE `users` SET `vcode` = '".$code."' WHERE `email` = '".$email."'");
//Email Code
$mail = new PHPMailer;
$mail->IsSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'fahmaanx@gmail.com'; //sender's email
$mail->Password = 'nrlm buth boxy nqcn'; //app password
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
$mail->setFrom('fahmaanx@gmail.com', 'Food Mart'); //sender's email, Sender's name
$mail->addReplyTo('fahmaanx@gmail.com', 'Food Mart'); //Sender's email, Sender's name
$mail->addAddress($email); //receiver's email
$mail->isHTML(true);
$mail->Subject = 'Your forgot password verification code'; //Subject of the email
$bodyContent = '
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Email Format</title>
<style>
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
background-color: #f8f9fa;
}
.container {
max-width: 600px;
margin: 40px auto;
padding: 20px;
background-color: white;
border: 1px solid #ddd;
border-radius: 6px;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
text-align: center;
}
.image-thumbnail {
width: 100%;
max-width: 150px;
margin: 20px auto;
border: 1px solid #ddd;
border-radius: 4px;
}
.code {
color: #155724;
background: #d4edda;
border-radius: 15px;
display: inline-block;
padding: 10px 20px;
margin: 20px 0;
font-size: 24px;
font-weight: bold;
text-align: center;
}
.number {
margin: 0;
text-align: center;
}
.contact {
margin: 40px 0 20px;
}
.contact a {
text-decoration: none;
color: #007bff;
font-weight: bold;
}
.contact a:hover {
text-decoration: underline;
}
h4 {
color: #333;
margin-bottom: 10px;
font-size: 22px;
}
p {
color: #555;
font-size: 16px;
line-height: 1.6;
}
small {
font-size: 14px;
color: #6c757d;
}
</style>
</head>
<body>
<div class="container">
<h4>FoodMart - Forgot Password Verification Code</h4>
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS664wHiP_KpnYqb75YRsBdq4AdQaLf0Ldf-dMk4fRR9mVO7Ydq" alt="" class="image-thumbnail">
<p>
<b>Hello There !</b><br>
<small> Welcome to FoodMart. We are excited to have you on board. <br>
You have requested to reset the password of your FoodMart account<br>Please find the security code to change your password <br>
</small>
<div class="code">
<h2 class="number">'.$code.'</h2>
</div>
<br>
<small>This code is valid for the next <b>5 minutes</b>. If you did not request this, please contact our support team.</small>
<br>
<div class="contact">
<small>Need assistance? <a href="">Contact Support</a></small><br>
<small>Read our <a href="">Privacy Policy</a></small><br>
<small>© 2024 FoodMart. All rights reserved.</small><br>
</div>
</p>
</div>
</body>
</html>
'; //content of the email
$mail->Body = $bodyContent;
if (!$mail->send()) {
echo ("Verification Code sending Failed");
} else {
echo ("success");
}
} else {
echo ("Email Address not found");
}
}
} else {
echo ("Please Enter Your Email Address");
}