-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpasswd_change.php
74 lines (64 loc) · 2.45 KB
/
passwd_change.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
<?php
session_start();
if(!isset($_SESSION['uid'])) $_SESSION['uid'] = 0;
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Sakura</title>
</head>
<body>
<?php
$title="Sakura";
$show_buttons = TRUE;
?>
<?php
include_once 'database_util.php';
include_once 'image_util.php';
?>
<?php
if(isset($_POST['call']))
{
}
include_once 'style.php';
include 'header.php';
?>
<div class="form" style="margin-top: 50px;">
<form method="post" action="">
原密码:<input type="password" name="passwd_old" class="login" required oninvalid=setCustomValidity("不可为空") oninput=setCustomValidity('')>
新密码:<input type="password" name="passwd_new1" class="login" required oninvalid=setCustomValidity("不可为空") oninput=setCustomValidity('')>
确认密码:<input type="password" name="passwd_new2" class="login" required oninvalid=setCustomValidity("不可为空") oninput=setCustomValidity('')>
<input type="submit" value="确认" class="login">
<input type="hidden" name="call" value="change">
</form>
<?php
if (isset($_POST['call']) and $_POST['call']=="change")
{
$sql = "SELECT * from sakura.user_info
where user_id = ".$_SESSION["uid"].
" AND user_pwd = PASSWORD('".$_POST['passwd_old']."')" ;
$retval = execute_sql($conn, $sql);
if (!mysqli_fetch_array($retval))
echo '<p style="text-align:center;"><font color="red">旧密码对上不能</font></p>';
else if (!preg_match("/^[a-zA-Z0-9_]{6,32}$/", $_POST['passwd_new1']))
echo '<p style="text-align:center;"><font color="red">密码请使用6-32字符的英文字母、数字、下划线!</font></p>';
else if ($_POST['passwd_new1'] != $_POST['passwd_new2'])
echo '<p style="text-align:center;"><font color="red">两次输入的密码不同!</font></p>';
else
{
$passwd_new = $_POST['passwd_new1'];
$sql = "UPDATE sakura.user_info
set user_pwd = PASSWORD('$passwd_new')
where user_id = ".$_SESSION['uid'];
execute_sql($conn, $sql);
echo '修改成功';
echo "<script language='javascript' type='text/javascript'>
window.location.href='/temp_page.php'
</script>";
}
}
?>
</div>
</body>
</html>