-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
219 lines (162 loc) · 5.58 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<?php
session_start();
if(isset($_SESSION["login"])){
header("Location: signout.php");
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Barbados Community College - Web Portal</title>
<link rel="shortcut icon" href="imgs/titleimg.gif" />
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
<link href = 'http://fonts.googleapis.com/css?family=Open+Sans' rel = 'stylesheet' = type = 'text/css'>
</head>
<body class="loginBody">
<div id="wrap" class="loginWrap">
<div id = "header">
<img src="imgs/bcclogo.gif" alt="logo" />
<span style="float: right; padding-top: 10px;"><img src="imgs/portal.png" alt="portal photo" width="" height="150px"/></span>
</div>
<div id = "menu">
<?php
if(empty($_SESSION)){
echo"<br/>
<br/>
<br/>";
}
else{
include("menu.php");
}
?>
</div>
<div id = "content" class="loginContent">
<h1>Barbados Community College - Web Portal</h1>
<div id="slideshow">
</div>
<br/>
<br/>
<form class="loginForm" style="width: 300px;" action='<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>' method='post'>
<h1>Login</h1>
Email: <input type='text' value="[email protected]" min='0' max='9999999' name='email' style="left: 40%" /><br/><br/>
Password: <input type='password' value="P@ssw0rd" name='pwd' style="left: 40%" /><br/>
<div id='bubble' class='bubble'>
<p id='message' class='message' style='padding: 10px; text-align: center; color: white; border-radius: 15px' ></p>
</div>
<input style="" type='submit' value='Login' />
<br/>
</form>
<br/><br/>
<?php
$id = $password = "";
//CHECKS IF PERSON HAS NOT LOGGED IN
if( $_SERVER["REQUEST_METHOD"] == "POST"){
if($_POST["email"] == "[email protected]"){
$_SESSION["id"] = 111;
$_SESSION["login"] = "yes";
$_SESSION["name"] = "Vincent Branker";
$_SESSION["typeOfUser"] = "tutor";
$_SESSION["division"] = "Computer Science";
//GET COURSE TUTOR TEACHES
$course1 = "Web Applications";
$course2 = "Major Project";
//WRITE IT TO THE MENU
include 'writemenu.php';
header("Location: tutordashboard.php");
}
else if($_POST["email"] == "[email protected]"){
$_SESSION["id"] = 111;
$_SESSION["login"] = "yes";
$_SESSION["name"] = "Samuel Rouse";
$_SESSION["typeOfUser"] = "seniortutor";
$_SESSION["division"] = 1;
header("Location: seniordashboard.php");
}
/*
$id = $_POST["id"];
$password = md5($_POST["pwd"]);
//ESTABLISH CONNECT
$con = mysqli_connect("localhost", "root", "");
//CONNECT TO DB
$db = mysqli_select_db($con, "sis");
//MAKE QUERY 1
$rs1 = mysqli_query($con, "SELECT * FROM users WHERE id=$id ");
if(!$con || !$db || !$rs1 ){
die("Error: ".mysqli_error($con));
}
else{
//IF USER IS FOUND IN USER TABLE DO THIS
if(mysqli_num_rows($rs1) > 0){
//GET DATA USERNAME AND PASSWORD FROM USERS TABLE
while($row = mysqli_fetch_array($rs1)){
$dbid = $row["id"];
$dbpassword = $row["password"];
$dbname = $row["name"];
$type = $row["typeOfUser"];
}
//VERIFICATION
if($id == $dbid && $password == $dbpassword){
$_SESSION["id"] = $dbid;
$_SESSION["login"] = "yes";
$_SESSION["name"] = $dbname;
$_SESSION["typeOfUser"] = $type;
if($type == "tutor"){
//MAKE QUERY
$rs = mysqli_fetch_array(mysqli_query("SELECT division_id,course1,course2 FROM tutors where id = $id ")) or die('Error: '.mysqli_error());
//GET COURSE TUTOR TEACHES
$course1 = $rs["course1"];
$course2 = $rs["course2"];
$_SESSION["division"] = $rs["division_id"];
//WRITE IT TO THE MENU
include 'writemenu.php';
//REDIRECT TO TUTOR DASHBOARD
header("Location: tutordashboard.php");
}
elseif($type == "seniortutor"){
$rs = mysqli_fetch_array(mysqli_query("SELECT division_id FROM tutors where id = $id ")) or die('Error: '.mysqli_error());
$_SESSION["division"] = $rs["division_id"];
header("Location: seniordashboard.php");
}
elseif($type == "student"){
//STUDENT DASHBOARD
header("Location: studentdashboard.php");
}
//SUCCESS
}
else{
echo '<script>
function msg(){
var msg = document.getElementById("message");
message.style.backgroundColor = "#a94442";
msg.innerHTML = "Incorrect username or password"
}
window.msg();
</script>
';
}
}
else{
echo '<script>
function msg(){
var msg = document.getElementById("message");
message.style.backgroundColor = "#a94442";
msg.innerHTML = "Incorrect username or password"
}
window.msg();
</script>
<br/>';
}
}
mysqli_close($con);
*/
}
?>
<p>Want to apply for a degree? Click <a href="apply.php">here</a> </p>
<a href='signup.php'>Sign up</a>
</div>
<div id = "footer" class="loginFooter">
<?php include 'footer.php';?>
</div>
</div>
</body>
</html>