-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforgotpsw.php
More file actions
159 lines (152 loc) · 5.04 KB
/
Copy pathforgotpsw.php
File metadata and controls
159 lines (152 loc) · 5.04 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
<?php
include 'connect.php';
if (isset($_POST['signup'])) {
$Name = $_POST['Name'];
$email = $_POST['email'];
$phoneNumber = "25" . $_POST['number'];
$password = $_POST['password'];
$repassword = $_POST['repassword'];
if ($password == $repassword) {
// Check if the username, email, and phone number exist
$userCheckQuery = "SELECT * FROM `users` WHERE name='$Name' AND email='$email' AND phone_number='$phoneNumber'";
$userCheckResult = mysqli_query($conn, $userCheckQuery);
if (mysqli_num_rows($userCheckResult) > 0) {
// Hash the new password
$hashedPassword = password_hash($password, PASSWORD_DEFAULT);
// Update the password in the database
$updateQuery = "UPDATE `users` SET `password`='$hashedPassword' WHERE name='$Name' AND email='$email' AND phone_number='$phoneNumber'";
$updateResult = mysqli_query($conn, $updateQuery);
if ($updateResult) {
echo '<script>alert("Password reset successfully. Please log in with your new password.");</script>';
header("location:login.php");
exit();
} else {
echo "Error updating the password: " . mysqli_error($conn);
}
} else {
echo '<script>alert("No user found with the provided name, email, and phone number. Please try again.");</script>';
}
} else {
echo '<script>alert("Passwords must match!");</script>';
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Reset Password</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
<style>
.login{
width: 50%;
float: left;
height: 100vh;
}
.bckgrnd{
width: 50%;
float: right;
background-image: url('Images/spring.jpg');
background-repeat: no-repeat;
background-size: cover;
background-position:center;
height: 150vh;
}
form{
margin:3em;
}
.img img{
width: 25em;
margin-left:7rem;
}
.login h3{
scale: 220%;
margin-left:21em;
width:100%;
}
.btn{
width: 10em;
}
.btn-log{
width: 10em;
padding: 3px;
border-radius: 10px;
margin-top: 1em;
margin-left: 3em;
background-color: darkblue;
color: white;
}
.btn-can{
width: 10em;
padding: 7px;
border-radius: 10px;
margin-top: 1em;
position: absolute;
margin-left: 12em;
border: 1px solid blue;
}
.forgotpwd{
margin-top: 2em;
text-decoration: none;
margin-left: 5.5em;
position: absolute;
text-align: center;
color: darkblue;
}
.check{
margin-left: 28em;
margin-top: 3em;
color: darkblue;
}
.adm{
margin-left:5.5rem;
margin-top:1rem;
position: absolute;
text-decoration:none;
font-weight:bold;
}
body{
overflow-x:hidden;
background-color:gold;
}
</style>
</head>
<body>
<div class="login">
<div class="container p-4">
<h4 class="text-success text-center fw-bold"><span class="text-success p-1 bg-light">Forgot Password?</span> <span class="text-light p-1 bg-success">Reset it Below</span></h4>
<form method="POST">
<div class="mb-3">
<label class="form-label fw-bold">Names</label>
<input type="text" class="form-control" id="Name" name="Name" placeholder="Enter name you used before" required>
</div>
<div class="mb-3">
<label class="form-label fw-bold">Email</label>
<input type="email" class="form-control" id="email" name="email" placeholder="Enter email you used before" required>
</div>
<div class="mb-3">
<label class="form-label fw-bold">Phone Number</label>
<input type="number" class="form-control" id="number" name="number" placeholder="Enter phone Number used before" required>
</div>
<div class="mb-3">
<label class="form-label fw-bold">New Password</label>
<input type="password" class="form-control" placeholder="Enter New Password Here" name="password" id="password" minlength="8" required>
</div>
<div class="mb-3">
<label class="form-label fw-bold">Password</label>
<input type="password" class="form-control" placeholder="Re-Enter Your New Password Here" name="repassword" id="repassword" required>
</div>
<button class="btn-log fw-bold bg-success" name="signup">Reset</button>
<button class="btn-can" type="reset" name="cancel">Cancel</button><br>
<a class="adm text-success" href="login.php">Or Login</a>
</div>
</div>
</form>
</div>
</div>
<div class="bckgrnd"></div>
<script src="js/bootstrap.bundle.min.js"></script>
</body>
</html>