-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverify.php
43 lines (43 loc) · 1.16 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
<?php
session_start();
if(isset($_SESSION['id'])){
header("location:index.php");
die();
}
?>
<!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
session_start();
if(isset($_SESSION['id'])){
header("location:index.php");
die();
}
$login=$_POST['login'];
$pwd=$_POST['pwd'];
$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;
?>
</body>
</html>