-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
41 lines (32 loc) · 1.11 KB
/
login.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
<?php
require 'common.php';
connect_mydb();
select_mydb();
$account=_POST('account');
$password=md5(_POST('password'));
//检查用户名是否存在
$result = mysqli_fetch_all(mysqli_query($mydb,"select * from user where account = '$account'"));
if(!$result){
echo"<script>alert('账号不存在');history.go(-1);</script>";
}
//检查用户名与密码是否匹配
else{
$row=mysqli_query($mydb,"select password from user where account ='$account'");
$row=mysqli_fetch_array($row,MYSQLI_ASSOC);
$mypassword=$row['password'];
if($mypassword!=$password){
echo"<script>alert('密码错误');history.go(-1);</script>";
}
else{
$row=mysqli_query($mydb,"select * from user where account ='$account'");
$row=mysqli_fetch_array($row,MYSQLI_ASSOC);
$identity=$row['identity'];
$realname=$row['realname'];
setcookie('account',$account,0);
setcookie('identity',$identity,0);
setcookie('realname',$realname,0);
echo '<script type="text/javascript">window.location.href="home.php"</script>';
}
}
mysqli_close($mydb);
?>