/
login.php
97 lines (49 loc) · 1.51 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
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
<?php
include('sqld.php');
session_start();
date_default_timezone_set('PRC');
$Name = $_POST['exampleInputName2'];
$Pass = $_POST['exampleInputPass2'];
$mysqli=sqli();
if (empty($Name)) {
echo "<script type='text/javascript'>
window.alert('用户名不能为空');
window.location.href='index.php';
</script>";
exit;
}elseif (empty($Pass)) {
echo "<script type='text/javascript'>
window.alert('密码不能为空');
window.location.href='index.php';
</script>";
exit;
}else{
$query = "select * from user where username='$Name'";
$sqlld = $mysqli->query($query);
if($sqlld->num_rows>0){
//echo "用户名存在";
$row = $sqlld->fetch_array();
if ($row[2]==md5($Pass)) {
$_SESSION['ID'] = $row[0];
$LoginDATE = date('Y-m-d H:i:s');
$query_1 = "update user set login_date='$LoginDATE',login_state='1' where id='$row[0]'";
$sqli_1 = $mysqli->query($query_1);
echo "<script type='text/javascript'>
window.location.href='index.php';
</script>";
}else{
echo "<script type='text/javascript'>
window.alert('密码不正确');
window.location.href='index.php';
</script>";
}
}else{
echo "<script type='text/javascript'>
window.alert('用户名不存在');
window.location.href='index.php';
</script>";
}
}
$sqlld -> free();
$mysqli -> close();
?>