-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
112 lines (86 loc) · 3.32 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php include("sessionMain.php"); ?>
<?php
include("config.php");
if($_SERVER["REQUEST_METHOD"] == "POST") {
// username and password sent from form
$myemail = mysqli_real_escape_string($db,$_POST['email']);
$mypassword = mysqli_real_escape_string($db,$_POST['password']);
$sql = "SELECT * FROM User WHERE Email = '$myemail' and Password = '" . md5($mypassword) . "'";
$result = mysqli_query($db,$sql);
$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
$usertype = $row['UserType'];
$count = mysqli_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count == 1) {
$_SESSION['login_user'] = $row['Username'];
$_SESSION['user_type'] = $usertype;
if($usertype == "ADMIN") {
header("Location: adminDashboard.php");
} else if($usertype == "OWNER") {
header("Location: ownerDashboard.php");
} else if($usertype == "VISITOR") {
header("Location: visitorDashboard.php");
} else {
header("Location: index.php");
}
} else {
echo "<script type='text/javascript'>alert('Incorrect username or password');</script>";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<?php include("head.php"); ?>
<body>
<?php include("loginNavbar.php"); ?>
<!--==========================
Main Section
============================-->
<section id="hero">
<div class="hero-container">
<!-- <h1>Welcome</h1> -->
<h2>Atlanta Gardens, Farms, and Orchards</h2>
<div class="card">
<div class="card-body">
<form class="form-horizontal" action='index.php' method='post'>
<fieldset>
<!-- Form Name -->
<legend>Login</legend>
<br>
<!-- Text input-->
<div class="form-group">
<div class="col-md-12">
<input id="email" name="email" type="text" placeholder="Email" class="form-control input-md" required="">
</div>
</div>
<!-- Password input-->
<div class="form-group">
<div class="col-md-12">
<input id="password" name="password" type="password" placeholder="Password" class="form-control input-md" required="">
</div>
</div>
<!-- Submit Button -->
<div class="col-md-12">
<input class="btn-get-started" type="submit" value="Login">
</div>
<br>
<div class="col-md-12">
<div class="row">
<!-- Registration Links -->
<div class="col-md-6">
<a class="btn btn-success style-bkg" href="newOwnerReg.php">New Owner Registration</a> <br>
</div>
<!-- Registration Links -->
<div class="col-md-6">
<a class="btn btn-success style-bkg" href="newVisitorReg.php">New Visitor Registration</a> <br>
</div>
</div> <!-- End Row -->
</div> <!-- End Column -->
</fieldset> <!-- End Fieldset -->
</form> <!-- End Form -->
</div> <!-- End Card Body -->
</div> <!-- End Card -->
</div>
</section>
</body>
</html>