-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverify.php
51 lines (47 loc) · 1.47 KB
/
verify.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
<?php
session_start();
if(isset($_SESSION["id"]))
{
header("location:index.php");
die();
}
else
{
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BeSmile Verify</title>
</head>
<body>
<?php
$username = $_POST['username'];
$password = $_POST['password'];
$conn = new PDO("mysql:host=localhost;dbname=webboard;charset=utf8", "root", "");
$sql = "SELECT * FROM user WHERE username='$username' AND password=sha1('$password')";
$result = $conn->query($sql);
if($result->rowCount()==1)
{
$data = $result->fetch(PDO::FETCH_ASSOC);
$_SESSION["username"] = $data['username'];
$_SESSION["role"] = $data['role'];
$_SESSION["user_id"] = $data['id'];
$_SESSION["id"] = session_id();
header("location:index.php");
die();
//echo "ยินดีต้อนรับคุณ ADMIN";
}
else
{
$_SESSION["error"] = "true";
header("location:login.php");
die();
//echo "ชื่อบัญชี หรือ รหัสผ่าน ไม่ถูกต้อง";
}
$conn = null;
?>
</body>
</html>
<?php } ?>