-
Notifications
You must be signed in to change notification settings - Fork 2
/
login.php
40 lines (33 loc) · 1.1 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
<?php
require_once('sql/mysql.php');
session_start();
$username = $_POST['username'];
$password = $_POST['password'];
if (!empty($username) && !empty($password)) {
$db = new \sql\MysqlPDO(0);
$list = $db->get_select(USER, "username='$username'");
if ($list['password'] != $password) {
echo "<script>
alert('密码错误!');
window.location='index.html';
</script>";
} elseif ($list['level'] == 3) {
$_SESSION[$username] = $list['level'];
$_SESSION['user'] = $list['username'];
header("Location:main.html");
} elseif ($username == 'admin') {
$_SESSION[$username] = $list['level'];
$_SESSION['user'] = $list['username'];
echo "<script>window.location='admin/manage_panel.php'</script>";
} else {
$_SESSION[$username] = $list['level'];
$_SESSION['user'] = $list['username'];
header("Location:main.html");
}
} else {
echo "<script>
alert('用户名或密码不为空!');
window.location='index.html';
</script>";
}
?>