-
Notifications
You must be signed in to change notification settings - Fork 3
/
login.php
89 lines (81 loc) · 2.33 KB
/
login.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
83
84
85
86
87
88
89
<?php
session_start();
require_once("dbconnect.php");
if(isset($_POST['login'])){
$u = $_POST['email'];
$p = $_POST['password'];
$query = "SELECT * FROM USERS WHERE email = '$u' AND password = '$p'";
$result = mysqli_query($connection, $query);
$row = mysqli_fetch_assoc($result);
if($row){
// Store userID in session
$_SESSION['cusID'] = $row['userID'];
$_SESSION['Name'] = $row['email'];
if($row['type'] == 'CUS'){
header('Location: customer.php');
} elseif($row['type'] == 'MGR'){
header('Location: manager.php');
} elseif($row['type'] == 'RDR'){
header('Location: rider.php');
}
}
else {
echo '<script>';
echo 'alert("Invalid Login Credentials")';
echo '</script>';
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Login</title>
</head>
<body>
<div class="container">
<h1 style="text-align: center; color: #265073; font-style: italic;">QuickEats</h1>
<form method="post" action="login.php">
<label for="email"><b>Email</b></label>
<input type="text" placeholder="Enter Email" name="email" required>
<label for="password"><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="password" required>
<button type="submit" name="login">Login</button>
</form>
</div>
<style>
body{
font-family: Arial, Helvetica, sans-serif;
background-color: #ecf4d6;
}
.container{
width: 300px;
padding: 16px;
background-color: white;
margin: 0 auto;
margin-top: 250px;
border: 1px solid black;
border-radius: 4px;
}
input[type=text], input[type=password] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #265073;
box-sizing: border-box;
}
button{
background-color: #265073;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 100%;
}
button:hover{
opacity: 0.8;
}
</style>
</body>
</html>