-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
69 lines (67 loc) · 2.99 KB
/
index.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
<?php
$conn=new mysqli('localhost', 'root', '', 'qlnhanvien1');
if(!$conn){
die("Không thể kết nối");
}
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/bootstrap.min.css">
<script src="js/jquery.min.js"></script>
<script src="js/popper.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<link rel="stylesheet" href="fontawesome-free-5.12.1-web/css/all.css">
<title>Document</title>
<link rel="stylesheet" href="css/index.css">
</head>
<body>
<div class="mn">
<div class="container">
<div class="danhnhap">
<ul class="list-group">
<li class="list-group-item text-center">
<h1><i class="fab fa-reddit" style="color: blue; font-size: 65px"></i></h1>
</li>
<li class="list-group-item">
<form action="index.php" method="post">
<div class="form-group cs">
<input type="text" class="form-control" id="username" placeholder="Nhập tên đăng nhập" name="username" required>
</div>
<div class="form-group cs">
<input type="password" class="form-control" id="pwd" placeholder="Nhập mật khẩu" name="password" required>
</div>
<input type="submit" class="bt" name="btngui" value="Đăng nhập">
<?php
if(isset($_POST['btngui'])){
$username=$_POST['username'];
$pass=$_POST['password'];
$pass=md5($pass);
$sql="select username, pass from users where username='$username'";
$result = $conn->query($sql);
if($result->num_rows == 0){
echo '<script language="javascript"> alert("Sai tên đăng nhập") </script>';
exit;
}
$row = $result->fetch_assoc();
if($pass != $row['pass']){
echo '<script language="javascript"> alert("Sai mật khẩu") </script>';
}
else{
$_SESSION['username']=$username;
$_SESSION['pass']=$pass;
header('location:home.php');
}
}
?>
</form>
</li>
</ul>
</div>
</div>
</div>
</body>
</html>