-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverify.php
67 lines (58 loc) · 1.62 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
session_start();
if(isset($_SESSION['id'])){
header("location:index.php");
die();
}
$login=$_POST['name'];
$pwd=$_POST['pass'];
$conn=new PDO("mysql:host=localhost;dbname=webboard;charset=utf8","root","");
$sql="SELECT * FROM user where login='$login' and password=sha1('$pwd')";
$result=$conn->query($sql);
if($result->rowCount()==1){
$data=$result->fetch(PDO::FETCH_ASSOC);
$_SESSION['username']=$data['login'];
$_SESSION['role']=$data['role'];
$_SESSION['user_id']=$data['id'];
$_SESSION['id']=session_id();
header("location:index.php");
die();
}else{
$_SESSION['error']="error";
header("location:login.php");
die();
}
$conn=null;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Verify</title>
</head>
<body>
<?php
if($_POST['name']=="admin" && $_POST['pass']=="ad1234"){
$_SESSION["username"]="admin";
$_SESSION["role"]="a";
$_SESSION["id"]=session_id();
header("location:index.php"); //redirect
die();
}
elseif($_POST['name']=="member" && $_POST['pass']=="mem1234")
{
$_SESSION["username"]="member";
$_SESSION["role"]="m";
$_SESSION["id"]=session_id();
header("location:index.php"); //redirect
die();
}
else{
$_SESSION['error']='error';
header("location:login.php");
die();
}
?>
</body>
</html>