-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchange_password.php
133 lines (116 loc) · 3.57 KB
/
change_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
<?php
ob_start();
session_start();
//importing pages
require 'connect.php';
//access controlling
if (!isset($_SESSION["memID"]) || !isset($_SESSION["password"])) {
header("location:index");
}
//assigning variables
$memID = $_SESSION['memID'];
$password = $_SESSION['password'];
?>
<!DOCTYPE html>
<html>
<head>
<title>Change Password</title>
<link type="image/jpg" rel="icon" href="logo.jpg" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- importing bootstrap -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!-- adding styles -->
<style>
body {
width: 100%;
height: 100%;
background-size: cover;
padding: 15px;
}
#one {
width: 100%;
height: 100%;
background-image: url('navbar.jpg');
background-size: cover;
}
.nav-pills>li.active>a,
.nav-pills>li.active>a:focus {
color: black;
background-color: #fcd900;
}
.nav-pills>li.active>a:hover {
background-color: #000000;
color: white;
}
</style>
</head>
<body>
<form action="change_password" method="post">
<div class="container"><br><br>
<h1 align='center'>Change Password</h1><br><br>
<div class="row" align="right">
<div class="col-md-4">
<h4>Old Password</h4>
</div>
<div class="col-md-4"><input class="form-control" type="password" name="old_password" required></div>
</div>
<div class="row" align="right">
<div class="col-md-4">
<h4>New Password</h4>
</div>
<div class="col-md-4"><input class="form-control" type="password" name="new_password" id="new_password"
required></div>
<div class="col-md-1" align="left"><a class="btn" onclick="myFunction()"><span
class="glyphicon glyphicon-eye-open"></span></a></div>
</div>
<div class="row" align="right">
<div class="col-md-4">
<h4>Re-enter Password</h4>
</div>
<div class="col-md-4"><input class="form-control" type="password" name="rnew_password" required></div>
</div><br>
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-4"><input class="form-control" type="submit" name="change" value="CHANGE"></div>
</div>
</div>
</form>
<script type="text/javascript">
$(document).ready(function () {
window.setTimeout(function () {
$(".alert").fadeTo(1500, 0).slideUp(500, function () {
$(this).remove();
});
}, 3000);
});
function myFunction() {
var x = document.getElementById("new_password");
if (x.type === "password") {
x.type = "text";
} else {
x.type = "password";
}
}
</script>
</body>
<?php
//displaying alerts & updating passwords
if (isset($_POST['change'])) {
if (md5($_POST['old_password']) != $password) {
//display_alerts("info","change_password","Old password is not correct");
} else {
if ($_POST['new_password'] != $_POST['rnew_password']) {
//display_alerts("info","change_password","New password are not matching");
} else {
//updating passwords
$new_password = md5($_POST['new_password']);
$update_password_query = "UPDATE `login_details` SET `password` = '" . $new_password . "' WHERE `login_details`.`username` = '" . $memID . "'";
$is_update_firstname_query_run = mysqli_query($connect, $update_password_query);
header("location:index");
}
}
}
?>
</html>