-
Notifications
You must be signed in to change notification settings - Fork 0
/
password-reset.php
119 lines (102 loc) · 2.97 KB
/
password-reset.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
<?php include("connection.php"); ?>
<!-- Include Dashboard -->
<?php include("user_dashboard.php"); ?>
<!-- Include Dashboard -->
<!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>Chnage Password</title>
</head>
<body>
<div id="page-wrapper" class="gray-bg dashbard-1">
<div class="content-main">
<!--banner-->
<div class="banner">
<h2>
<a href="index.php">Home</a>
<i class="fa fa-angle-right"></i>
<span>Change password</span>
</h2>
</div>
<div class="grid-form">
<div class="grid-form1">
<h3 id="forms-example" class="">Change Your Password!</h3>
<hr>
<form method="post">
<div class="form-group">
<h4 style="padding-left:20px;">Current Password</h4>
<input type="password" name="cr_pass" class="form-control cat" required="">
</div>
<div class="form-group">
<h4 style="padding-left:20px;">New Password</h4>
<input type="password" name="npass" class="form-control cat" required="">
</div>
<div class="form-group">
<h4 style="padding-left:20px;">Confirm Password</h4>
<input type="password" name="c_pass" class="form-control cat" required="">
</div>
<button style="border-radius:10%; margin-left:20px;" name="btn" type="submit" class="btn btn-dark">Save Changes</button>
<!-- PHP Start -->
<?php
if(isset($_POST['btn']))
{
$username = $_SESSION['user'];
$query = "select * from user_info where username = '$username' ";
$run = mysqli_query($con,$query);
$row = mysqli_fetch_array($run);
$user_pass = $row[3];
$user_id = $row[0];
$current_Pasword = $_POST['cr_pass'];
$new_Pasword = $_POST['npass'];
$confirm_Pasword = $_POST['c_pass'];
if($current_Pasword == $user_pass)
{
if($new_Pasword == $confirm_Pasword)
{
$update_query = "update user_info set password = '$new_Pasword' where id = '$user_id' ";
$run_query = mysqli_query($con,$update_query);
if($run_query)
{
echo"
<div class='alert alert-success' role='alert'>
<b>Successfull!</b>Password has bees Changed Successfully...
</div>
";
}
else
{
echo"
<div class='alert alert-danger' role='alert'>
<b>Error!</b>Password Changing Failed!
</div>
";
}
}
else
{
echo"
<div class='alert alert-danger' role='alert'>
<b>Error!</b>New Password and Confirm Password must be identical...
</div>
";
}
}
else
{
echo"
<div class='alert alert-danger' role='alert'>
<b>Error!</b>Password is Invalid..
</div>
";
}
}
?>
<!-- End of PHP code -->
</div>
</div>
</div>
</body>
</html>