-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin_dashboard.php
More file actions
147 lines (100 loc) · 4.57 KB
/
Copy pathadmin_dashboard.php
File metadata and controls
147 lines (100 loc) · 4.57 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
<?php require_once("./includes/header_admin.php"); ?>
<!--..............................CheckAll Java script start..............................--
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>-->
<script src="./js/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
// Check/Uncheck ALl
$('#checkAll').change(function(){
if($(this).is(':checked')){
$('input[name="update[]"]').prop('checked',true);
}else{
$('input[name="update[]"]').each(function(){
$(this).prop('checked',false);
});
}
});
// Checkbox click
$('input[name="update[]"]').click(function(){
var total_checkboxes = $('input[name="update[]"]').length;
var total_checkboxes_checked = $('input[name="update[]"]:checked').length;
if(total_checkboxes_checked == total_checkboxes){
$('#checkAll').prop('checked',true);
}else{
$('#checkAll').prop('checked',false);
}
});
});
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;
return true;
}
</script>
<!--..............................CheckAll Java script end..............................-->
<!--........................................Change Password...................................-->
<?php
//Change password code
if (isset($_POST['change-password-btn'])) {
$roll_no = $_SESSION['roll_no'];
$current_password=trim($_POST['current-password']);
$new_password=trim($_POST['new-password']);
$password_hash = password_hash($new_password, PASSWORD_BCRYPT,);
$confirm_password=trim($_POST['confirm-password']);
$sql_roll_chk = "SELECT * FROM USERS where roll_no='$roll_no'";
$stmt_roll_chk = $pdo->prepare($sql_roll_chk);
$stmt_roll_chk->execute();
$user = $stmt_roll_chk->fetch(PDO::FETCH_ASSOC);
$user_password_hash = $user['password'];
if ($new_password != $confirm_password) {
echo "<center><font color=\"red\">New Password and confirm password does not match</br></font></center>";
$_POST['change-password']='change-password';
}elseif (password_verify($current_password, $user_password_hash)){
$sql_password_update = "UPDATE USERS SET password='$password_hash' where roll_no='$roll_no'";
$stmt_password_update = $pdo->prepare($sql_password_update);
$stmt_password_update->execute();
session_destroy();
?>
<center><font color="red" size="5"> Password updated successfully</font></center>
<?php
//header("Location=./session_logout.php");
//header("url: ../session_logout.php");
}else{
echo "<center><font color=\"red\">Wrong Current password</font></center>";
$_POST['change-password']='change-password';
}
}
//Change password form generation
if (isset($_POST['change-password'])) {
?>
<center><font color="green"><strong>Change Password</strong></font></center>
<center><font color="blue">After password changed, you will be logged out. You need to login again using new password.</font></center>
<form action="" method="POST">
<table align="center" border="1">
<tr style="color:purple"><td>Current Password</td>
<td>
<input name="current-password" id="inputCurrentPassword" type="password" placeholder="Enter current password" required="true" style="width: 300px;" minlength="3" maxlength="12" />
</td>
</tr>
<tr style="color:purple"><td>New Password</td>
<td>
<input name="new-password" id="inputNewPassword" type="password" placeholder="Enter new password" required="true" style="width: 300px;" minlength="6" maxlength="12" />
</td>
</tr>
<tr style="color:purple"><td>Confirm New Password</td>
<td>
<input name="confirm-password" id="inputConfirmPassword" type="password" placeholder="Confirm new password" required="true" style="width: 300px;" minlength="6" maxlength="12"/>
</td>
</tr>
<tr align="center">
<td colspan=2 ><button type="submit" name="change-password-btn" style="background-color:yellow;margin:auto;display:block;text-align:center;" >Change Password</button></td>
</tr>
</table>
</form>
<?php
}
?>
<?php require_once("./updates.php"); ?>
<?php require_once("./includes/footer.php"); ?>