-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchangepass.php
205 lines (157 loc) · 6.87 KB
/
changepass.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
<?php
session_start();
$_SESSION["cpass"]= false;
include './config/db.php';
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$mobile = $_POST["mobile"];
$password = $_POST["password"];
$cpass=$_POST["cpassword"];
if ($mobile != "" && $password != "" && $cpass!="")
{
$sql = "SELECT * FROM student where smobile=$mobile";
$result = mysqli_query($conn, $sql);
$num = mysqli_num_rows($result);
if ($num == 1) {
if($password!=$cpass){
echo '<div class="alert alert-success" >
<strong>Error! </strong> Password and Confirm Password must be same
</div>';
}
else
{
$hash = password_hash($password, PASSWORD_DEFAULT);
$sql1="UPDATE `student` SET `spassword`='$hash' WHERE smobile LIKE '$mobile'";
$res1=mysqli_query($conn,$sql1);
if($res1){
$_SESSION['cpass']=true;
header("location: ./login.php");
}
}
}
else {
echo '<div class="alert alert-danger" >
<strong>Error! </strong> Invalid Credentials
</div>';
}
}
else
{
echo '<div class="alert alert-danger" >
<strong>Error! </strong> please fill required details ..!!
</div>';
}
}
?>
<!DOCTYPE html>
<html lang="en">
<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>Forgot Password | HMS</title>
<!-- Favicon -->
<link href="img/favicon.ico" rel="icon">
<!-- Google Web Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Heebo:wght@400;500;600;700&family=Montserrat:wght@400;500;600;700&display=swap" rel="stylesheet">
<!-- Icon Font Stylesheet -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.10.0/css/all.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css" rel="stylesheet">
<link href="lib/tempusdominus/css/tempusdominus-bootstrap-4.min.css" rel="stylesheet" />
<!-- Customized Bootstrap Stylesheet -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Template Stylesheet -->
<link rel="stylesheet" href="./css/nav.css">
<link rel="stylesheet" href="./css/footer.css">
<link rel="stylesheet" href="./css/ftcustm.css">
<link rel="stylesheet" href="./css/register.css">
<link rel="stylesheet" href="./css/login.css">
<link rel="stylesheet" href="./css/sweetalert.css">
</head>
<body>
<div class="container bg-white p-0">
<?php include './partial/nav.php'; ?>
<section class="py-5" style="background-color: #508bfc;">
<div class="container py-2">
<div class="row d-flex justify-content-center align-items-center">
<div class="col-12 col-md-8 col-lg-6 col-xl-5">
<div class="card shadow-2-strong">
<div class="card-body p-5 text-center">
<h3 class="mb-3">Forgot Password</h3>
<form action="./changepass.php" method="post">
<div class="form-outline mb-4">
<input type="tel" class="form-control form-control-lg" name="mobile" placeholder="Enter Mobile " onkeypress="return isNumber(event)" />
</div>
<div class="form-outline mb-4">
<input type="password" id="password" class="form-control form-control-lg" placeholder="New Password" name="password" />
</div>
<div class="form-outline mb-4">
<input type="password" id="cpassword" class="form-control form-control-lg" placeholder="Confirm New Password" name="cpassword" onblur="passcheck()" />
</div>
<!-- Checkbox -->
<div class="form-check d-flex justify-content-start mb-4">
<input class="form-check-input" type="checkbox" onclick="myFunction()" />
<label class="ms-2 form-check-label" for="form1Example3"> Show password </label>
</div>
<div class="form-check d-flex justify-content-start mb-4">
<button class="btn btn-primary btn-lg btn-block btn-outline-dark" type="submit">Submit</button>
<a href="./login.php" class="forgot mt-2">Go back to login</a>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</section>
<?php include './partial/footer.php'; ?>
<!-- Back to Top -->
<a href="#" class="btn btn-lg btn-primary btn-lg-square back-to-top"><i class="bi bi-arrow-up"></i></a>
</div>
</body>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<!-- main page js -->
<script src="js/main.js"></script>
<script src="./js/sweetalert.js"></script>
<script>
$(".alert").fadeTo(2000, 500).fadeOut(500, function() {
$(".alert").fadeOut(500);
});
function myFunction() {
var y = document.getElementById("password");
var z = document.getElementById("cpassword");
if (y.type === "password" && z.type === "password") {
y.type = "text";
z.type = "text";
} else {
y.type = "password";
z.type = "password";
}
}
function passcheck() {
var p = document.getElementById("password").value;
var q = document.getElementById("cpassword").value;
if (p != q) {
Swal.fire({
icon: 'error',
title: '!...Error...!',
text: 'password and confirm password value mismatch..!',
})
}
else
{
return;
}
}
function isNumber(evt) {
evt = (evt) ? evt : window.event;
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
return false;
}
return true;
}
</script>
</html>