-
Notifications
You must be signed in to change notification settings - Fork 0
/
logUserIn.php
40 lines (33 loc) · 1.07 KB
/
logUserIn.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
<?php
if (isset($_POST['login'])) {
$error_messages = array();
$username = $_POST['username'];
$password = $_POST['password'];
include './includes/db.php';
$db = new DB;
$result = $db->getUserPassword(($username));
if ($result == "User Not Found") {
array_push($error_messages, "User Not Found");
include './login.php';
}
if ($result !=="User Not Found" && $password == $result ) {
$user = $db->getUser($username);
$admin = $db->getAdminStatus($user[0]);
session_start();
$_SESSION['admin'] = $admin;
$_SESSION["oracle_no"] = $user[0];
$_SESSION["name"] = $user[1];
$_SESSION["image"] = $user[2];
$_SESSION["username"] = $user[3];
$_SESSION["designation"] = $user[4];
$_SESSION["location"] = $user[5];
$_SESSION["grade"] = $user[6];
$_SESSION["role"] = $user[7];
header("Location: Dashboard/dashboard.php");
}
if ($result !=="User Not Found" && $password !== $result) {
array_push($error_messages, "Password is not correct");
include './login.php';
}
}
?>