-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
111 lines (106 loc) · 3.04 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
<?php
require_once 'filehead.php'; //include filehead file
$smarty->assign('CSS_URL', CSS_URL);
$smarty->display('header.tpl');// include header file
if(isset($_SESSION['username'])) //if already logged in
{
switch($_SESSION['type']) //checking user type
{
case 0:
{
header('Location:' . URL . 'adminhp.php');
break;
}
case 1:
{
$staffId=new staff();
$_SESSION['staffid']=$staffId->get('staffid',$_SESSION['username']);
switch($_SESSION['staffid'])
{
case '0':
{
header('Location:'.URL.'transporthp.php');
break;
}
case '1':
{
header('Location:'.URL.'accounthp.php');
exit;
break;
}
case '2':
{
header('Location:'.URL.'managinghp.php');
break;
}
}
break;
}
case 2:
{
header('Location:'.URL.'userhp.php');
break;
}
}
} else { //if no one was logged in
if (isset($_POST['submit']))
{
if((isset($_POST['username'])) && (isset($_POST['password'])) && (($_POST['username'])!=NULL)&&(($_POST['password'])!=NULL)) //check all fields filled
{
$login=new login();
if(($login->checkAuthentication($_POST['username'], $_POST['password']))) //check authentication
{
$_SESSION['username']=$_POST['username']; //setting session parameters
$_SESSION['type']=$login->get('type',$_POST['username']);
$_SESSION['userid']=$login->get('userid',$_POST['username']);
$time=date("d-m-Y h:i:sa");
$_SESSION['last_login']=strtotime($time);
$login->update('last_login',$_SESSION['last_login'],$_SESSION['userid']); //add last login
switch($_SESSION['type']) //checking user type
{
case 0:
{
header('Location:' . URL . 'adminhp.php');
break;
}
case 1:
{
$staff=new staff();
$_SESSION['staffid']=$staff->get('staffid',$_POST['username']);
switch($_SESSION['staffid'])
{
case 0:
{
header('Location:'.URL.'transporthp.php');
break;
}
case 1:
{
header('Location:'.URL.'accounthp.php');
break;
}
case 2:
{
header('Location:'.URL.'managinghp.php');
break;
}
}
break;
}
case 2:
{
header('Location:'.URL.'userhp.php');
break;
}
}
}else {
echo "MESSAGE : Wrong info..please enter again";
}
} else {
echo "MESSAGE: Incomplete login information..please enter";
}
}
$smarty->display('index.tpl'); //include 'index.tpl';
$smarty->display('footer.tpl'); //include footer
}
?>