-
Notifications
You must be signed in to change notification settings - Fork 27
/
update_password.php
171 lines (160 loc) · 5.01 KB
/
update_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
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
<?php
session_start();
include_once 'conn.php';
$addnew=$_POST["addnew"];
date_default_timezone_set('PRC');
$ndate =date("Y-m-d");
?>
<script src="js/jquery-2.1.3.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/sweetalert.min.js" type="text/javascript" charset="utf-8"></script>
<?php
if($addnew=="1")
{
//MD5加盐加密
$salt="skjddq237:&*^$df234GJSN";
$old_password=$_POST['old_password'];
$old_password=$old_password+$salt;
$old_password=md5($old_password);
$new_password=$_POST['new_password'];
$new_password=$new_password+$salt;
$new_password=md5($new_password);
$re_password=$_POST['re_password'];
$sql="select * from allusers where username='".$_SESSION['username']."'";
$query=mysql_query($sql);
$rowscount=mysql_num_rows($query);
if($rowscount>0)
{
if(mysql_result($query,0,"pwd") == $old_password)
{
$sql="update allusers set pwd='$new_password' where username='".$_SESSION['username']."'";
$query=mysql_query($sql);
echo
"<script>
$(function(){
swal('成功','修改密码!','success').then(() => {
history.back();
})});
</script>";
}
else
{
echo
"<script>
$(function(){
swal('失败','原密码不准确','error').then(() => {
history.back();
})});
</script>";
}
}
else
{
echo
"<script>
$(function(){
swal('失败','原密码不准确','error').then(() => {
history.back();
})});
</script>";
}
}
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>管理员修改密码</title>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/jquery.mCustomScrollbar.min.css" />
<link rel="stylesheet" href="css/custom.css" />
<link rel="stylesheet" href="css/demo_add.css" />
<link rel="stylesheet" href="css/font-awesome.min.css" />
<link rel="stylesheet" href="css/style.css" />
</head>
<script>
function check()
{
if(document.getElementById('old_password').value =="")
{
swal({
title: "失败!",
text: "请输入原密码!",
icon: "error",
showConfirmButton: true
})
document.getElementById('old_password').focus();
return false;
}
if(document.getElementById('new_password').value =="")
{
swal({
title: "失败!",
text: "请输入新密码!",
icon: "error",
showConfirmButton: true
})
document.getElementById('new_password').focus();
return false;
}
if(document.getElementById('re_password').value =="")
{
swal({
title: "失败!",
text: "请输入确认密码!",
icon: "error",
showConfirmButton: true
})
document.getElementById('re_password').focus();
return false;
}
if (document.getElementById('new_password').value != document.getElementById('re_password').value)
{
swal({
title: "失败!",
text: "两次密码不一致!",
icon: "error",
showConfirmButton: true
})
document.getElementById('new_password').value="";
document.getElementById('re_password').value="";
document.getElementById('new_password').focus();
return false;
}
}
</script>
<body>
<!--管理员密码修改-->
<div class="add_admin">
<div class="clearfix admin_con_top">
<h2 class="fl">修改管理员密码</h2>
<p class="fr">当前日期: <?php echo $ndate; ?></p>
</div>
<form id="form1" name="form1" method="post" action="" autocomplete="off">
<ul>
<li>
<span class="user">原密码:</span>
<input type="password" name="old_password" id="old_password" value='' placeholder="原密码" class="admin_name" autocomplete="new-password" readonly onFocus="this.removeAttribute('readonly');" onBlur="this.setAttribute('readonly',true);"/>*
<input type="hidden" name="addnew" value="1" />
<input type='text' style='display:none'> <!-- 针对firefox -->
</li>
<li>
<span class="password">新密码:</span>
<input type="password" name="new_password" id="new_password" class="pass admin_password1" value='' placeholder="新密码" autocomplete="new-password" readonly onFocus="this.removeAttribute('readonly');" onBlur="this.setAttribute('readonly',true);"/>*
<input type='password' style='display:none'> <!-- 针对firefox -->
</li>
<li>
<span class="password">确认密码:</span>
<input type='password' autocomplete="new-password" name="re_password" id="re_password" class="pass admin_password2" value='' placeholder="确认密码" readonly onFocus="this.removeAttribute('readonly');" onBlur="this.setAttribute('readonly',true);" />*
<input type='password' style='display:none'> <!-- 针对firefox -->
</li>
</ul>
<div class="bottom_box">
<input type="submit" name="Submit" value="修改" onClick="return check();">
<input type="reset" name="Submit2" value="重置"/>
<input type="hidden" name="addnew" value="1" />
</div>
</form>
</div>
<!--管理员密码修改end-->
</body>
<script>
</script>
</html>