-
Notifications
You must be signed in to change notification settings - Fork 0
/
loginfunction.php.bak_10072015
58 lines (47 loc) · 1.35 KB
/
loginfunction.php.bak_10072015
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
<?php
session_start();
include('connection.php');
$username=$_POST['username'];
$password=$_POST['password'];
if(!empty($username) && !empty($password))
{
$command="select * from user WHERE username = '".$username."' and password='".$password."'";
$result1=mysql_query($command);
$count=mysql_num_rows($result1);
$utype_id = "SELECT utype_id FROM user WHERE username='$username'";
$result2 = mysql_query($utype_id);
$result3 = mysql_fetch_row($result2);
if($count==0)
{
header("location:login.php?attempt=fail");
}
else{
$sql="select * from user WHERE username='".$username."'";
$result=mysql_query($sql);
while($row=mysql_fetch_row($result)){
// die(_a($row));
$_SESSION["id"]=$row[0];
$_SESSION["dept_id"]=$row[3];
$_SESSION["username"]=$row[6];
switch($result3[0]){
case '1':
header("location:dean/home.php");
break;
case '2':
header("location: registrar/home.php");
break;
case '3':
header("location:faculty/home.php");
break;
default:
header("location:login.php?attempt=unauthorized");
break;
}
}
}
}
else
{
header("location:login.php?attempt=null");
}
?>