-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchpasswd.php
More file actions
67 lines (63 loc) · 1.68 KB
/
Copy pathchpasswd.php
File metadata and controls
67 lines (63 loc) · 1.68 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
<?
session_start();
include("mysql-connect.php");
check();
?>
<?
$id=$_SESSION['id'];
if(isset($_POST['btn'])){
$newp=$_POST['newp'];
$newp2=$_POST['newp2'];
$oldp=$_POST['oldp'];
if(preg_match("/[^(\w|\d)]+/",$_POST['newp']) )
echo "<div class=error>含有不合法字元,請重新輸入</div>";
else{
if($newp!=$newp2){
echo "<div class=error>重複新密碼輸入錯誤</div>";
}
else{
$o=mysql_fetch_row(mysql_query("select passwd from school where id='$id'"));
if(sha1($oldp)!=$o[0]){
echo "<div class=error>舊密碼輸入錯誤</div>";
}
else{
$new=sha1($newp);
mysql_query("update school set passwd='$new' where id='$id'");
echo "修改成功";
}
}
}
}
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="style.css" />
<head>
<title>更改密碼</title>
</head>
<br><br><br><br>
<body>
<div align="center">
<form action="#" method="post">
<table height="30%" border="0">
<tr>
<td><strong>新密碼</td>
<td><input type="password" name=newp></td>
</tr>
<tr>
<td><strong>重複新密碼</td>
<td><input type="password" name=newp2></td>
</tr>
<tr>
<td><strong>舊密碼</td>
<td><input type="password" name=oldp></td>
</tr>
<tr>
<td colspan=2 align="center">(只允許含有英文大小寫以及數字)</td>
</tr>
<tr>
<td colspan=2 align="center"><input type="submit" name="btn" value="確認"></td>
</tr>
</table>
</form>
</div>
</body>