-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathM_Update_Account_Password.php
254 lines (228 loc) · 8.78 KB
/
M_Update_Account_Password.php
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
<?php require_once('connection.php');
session_start();
/**
* @author Yasiru
* contact me : https://linktr.ee/yasiruchamuditha for more information.
*/
//Import PHPMailer classes into the global namespace
//These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
//Load Composer's autoloader
//require 'vendor/autoload.php';
require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';
//
$alertMessage = '';
$redirectLocation = '';
if(isset($_POST["btnSubmit"]))
{
if (isset($_SESSION["Email"]))
{
//create a new PHPMailer object:
$mail = new PHPMailer(true);
$Email=$_POST["txtEmail"];
$Password=$_POST["txtPassword"];
if(empty($Email) || empty($Password))
{
$alertMessage = "Fileds cannot be blank";
$redirectLocation = "M_Update_Account_Password.php";
}
else
{
if (!filter_var($Email, FILTER_VALIDATE_EMAIL))
{
$alertMessage = "Please Enter Valid UserEmail";
$redirectLocation = "M_Update_Account_Password.php";
}
else
{
//perform sql
$sql1 = "SELECT * FROM user_registration WHERE Password='$Password' and Email='$Email' ";
$result= mysqli_query($con, $sql1);
$num_row = mysqli_num_rows($result);
if ($num_row >0)
{
$alertMessage = "Completed";
$redirectLocation = "M_Update_Password.php";
}
else
{
$alertMessage = "Invalid Username and Password Combination";
$redirectLocation = "M_User_Login.php";
}
}
}
}
else
{
$alertMessage = "Please Sign In";
$redirectLocation = "M_User_Login.php";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Login</title>
<!-- Font Awesome -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.0/css/all.min.css" rel="stylesheet">
<link href="https://unpkg.com/[email protected]/css/boxicons.min.css" rel="stylesheet"/>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-geWF76RCwLtnZ8qwWowPQNguL3RmwHVBC9FhGdlKrxdiJJigb/j/68SIy3Te4Bkz" crossorigin="anonymous"></script>
<link href="css/M_Forgotten.css" rel="stylesheet">
<script src="https://kit.fontawesome.com/c4254e24a8.js" crossorigin="anonymous"></script>
</head>
<body style="background: url(img/Token1.png);">
<?php require('M_NavigationBarForms.php');?>
<div class="container-fluid" id="containerm">
<div class="container">
<h1>Reset Password</h1>
<?php if (!empty($alertMessage)) : ?>
<div class="modal fade" id="outputModal" tabindex="-1" aria-labelledby="outputModalLabel"
aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="outputModalLabel">Output Message</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"
aria-label="Close"></button>
</div>
<div class="modal-body">
<?php echo $alertMessage; ?>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function () {
var modal = new bootstrap.Modal(document.getElementById('outputModal'));
modal.show();
// Redirect after displaying the message
var redirectLocation = '<?php echo $redirectLocation; ?>';
if (redirectLocation) {
setTimeout(function () {
window.location.href = redirectLocation;
}, 3000); // Redirect after 3 seconds (adjust as needed)
}
});
</script>
<?php endif; ?>
<form action="#" method="post" name="frmlogin" autocomplete="off" onsubmit="return validateForm()">
<label for="headling" class="form-label" >Please verify Your Account Before Reset Password</label>
<div class="inputfeild mt-3">
<label for="UserEmail" class="form-label" >UserEmail</label>
<div class="input-field">
<input type="email" name="txtEmail" id="txtEmail" class="email form-control" placeholder="UserEmail" onkeyup="validateEmail()">
</div>
<span id="Email_Error"></span>
</div>
<div class="inputfeild mt-3">
<label class="form-label mb-2">Password:</label>
<div class="input-group">
<input type="password" class="form-control" name="txtPassword" id="txtPassword" placeholder="Enter Password" onkeyup="validatePassword()">
<button type="button" class="btn btn-outline-secondary" id="showPasswordBtn">
<i class="bx bx-hide show-hide"></i>
</button>
</div>
<span id="Password_Error"></span>
</div>
<div class="input-field button">
<input type="submit" class="btn btn-outline-primary btn-lg" name="btnSubmit"id="btnSubmit" value="Submit">
</div>
</form>
</div>
</div>
<!-- JavaScript -->
<script>
// Function to toggle password visibility
function togglePasswordVisibility(inputId, buttonId) {
const passwordInput = document.getElementById(inputId);
const showHideButton = document.getElementById(buttonId);
if (passwordInput.type === "password") {
passwordInput.type = "text";
showHideButton.innerHTML = '<i class="bx bx-show show-hide"></i>';
} else {
passwordInput.type = "password";
showHideButton.innerHTML = '<i class="bx bx-hide show-hide"></i>';
}
}
// Event listeners for the show/hide buttons
document.getElementById("showPasswordBtn").addEventListener("click", function () {
togglePasswordVisibility("txtPassword", "showPasswordBtn");
});
document.getElementById("showConfirmPasswordBtn").addEventListener("click", function () {
togglePasswordVisibility("txtConfirm_Password", "showConfirmPasswordBtn");
});
</script>
<script type="text/javascript" >
//Validtion
var Email_Error=document.getElementById('Email_Error');
var Password_Error=document.getElementById('Password_Error');
//VALIDATE EMAIL
function validateEmail()
{
var Email = document.getElementById('txtEmail').value.replace(/^\s+|\s+$/g, "");
if (Email.length == 0)
{
Email_Error.innerHTML='Email is required.';
return false;
}
else
{
var emaiPattern = /^[^ ]+@[^ ]+\.[a-z]{2,3}$/;
if (!Email.match(emaiPattern))
{
Email_Error.innerHTML='Please Enter Email in correct format.';
return false;
}
Email_Error.innerHTML = '<i class="fa-regular fa-circle-check"></i>';
return true;
}
}
//VALIDATE PASSWORD
function validatePassword()
{
var pass = document.getElementById('txtPassword').value.replace(/^\s+|\s+$/g, "");
if (pass.length == 0)
{
Password_Error.innerHTML='Password is required.';
return false;
}
else
{
var passPattern =/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/;
if (!pass.match(passPattern))
{
Password_Error.innerHTML='Please enter atleast 8 charatcer with number, symbol, small and capital letter.';
return false;
}
Password_Error.innerHTML = '<i class="fa-regular fa-circle-check"></i>';
return true;
}
}
//ON SUBMIT FORM
function validateForm()
{
validateEmail();
validatePassword();
if((!validateEmail() )|| (!validatePassword()) )
{
return false;
}
}
</script>
<?php require('M_Footer.php');?>
</body>
</html>