-
Notifications
You must be signed in to change notification settings - Fork 1
/
loginVerify.php
35 lines (33 loc) · 1.09 KB
/
loginVerify.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
<?php
require_once("connectDB.php");
session_start();
$db = connectToDB();
$table = "professor";
$emailCol = "profEmail";
if (isset($_SESSION["student"])) {
$table = "StudentTable";
$emailCol = "email";
}
$email = $_POST["email"];
$pass = $_POST["password"];
$query = "select * from $table where $emailCol = '$email' and password = PASSWORD('$pass')";
$result = $db->query($query);
if (!$result) {
die("Retrieval failed: ". $db->error);
} else if($result->num_rows == 0) {
echo "No entry exists in the database for the specified email and password";
} else {
echo "User Found";
$result->data_seek(0);
$row = $result->fetch_array(MYSQLI_ASSOC);
var_dump($row);
if($table == "professor"){
$_SESSION["profProfile"] = $row;
header("Location: professorProfile.php");
} else {
$_SESSION["studentProfile"] = $row;
header("Location: studentProfile.php");
}
}
$db->close();
?>