-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
82 lines (61 loc) · 1.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
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
session_start();
include('conncet.php');
?>
<!DOCTYPE html>
<html>
<head>
<title>Voyager - Login</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="center">
<h1>Login</h1>
<form name="f1" action="index.php" method="POST">
<div class="txt_field">
<input type="text" name="user" required />
<span></span>
<label>User ID</label>
</div>
<div class="txt_field">
<input type="password" name="pass" required />
<span></span>
<label>PIN</label>
</div>
<input type="submit" name="submit" value="Login" />
<div class="signup_link">
Cannot Find Your Account? <a href="registration.php">Register</a>
</div>
<div><br /></div>
</form>
</div>
<?php
if(isset($_POST['submit']))
{
$username= $_POST['user'];
$password= $_POST['pass'];
$sql = "select *from user where User_ID = '$username' and pin = '$password'";
$result = mysqli_query($conn , $sql);
$count = mysqli_num_rows($result);
$row = $result->fetch_assoc();
if($count==1)
{
$_SESSION['userID'] = $row['User_ID'];
$_SESSION['password'] = $row['pin'];
$_SESSION['mail'] = $row['Email'];
$_SESSION['name'] = $row['Name'];
// for Debug
// echo $_SESSION['userID'];
// echo $_SESSION['password'];
// echo $_SESSION['mail'];
// echo $_SESSION['name'];
header("Location: search.php?login=success");
}
else
{
echo "<h1><center></center> Login failed. Invalid username or password.</h1>";
}
}
?>
</body>
</html>