-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauthenticate.php
More file actions
67 lines (46 loc) · 1.21 KB
/
authenticate.php
File metadata and controls
67 lines (46 loc) · 1.21 KB
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
<?php
require 'mysql_connect.php';
$username =$_POST["user"];
$password =$_POST["password"];
$qUser = "SELECT * FROM users where username='$username' AND password=SHA('$password')";
$eUser = mysql_query($qUser);
echo $eUser;
if(mysql_num_rows($eUser)==1){
$getType = mysql_result($eUser,0,3);
session_start();
switch($getType){
case "admin":{
$_SESSION["userid"] = mysql_result($eUser,0,1);
$_SESSION["type"] = "admin";
header("Location:admin/sname.php");
break;
}
case "student":{
$_SESSION["userid"] = mysql_result($eUser,0,1);
$_SESSION["type"] = "student";
header("Location:student/sname.php");
break;
}
case "operator":{
$_SESSION["userid"] = mysql_result($eUser,0,1);
$_SESSION["type"] = "operator";
header("Location:operator/sname.php");
break;
}
case "faculty":{
$_SESSION["userid"] = mysql_result($eUser,0,1);
$_SESSION["type"] = "faculty";
header("Location:faculty/sname.php");
break;
}
}//end switch statement
}
else {
?>
<script>
alert("<?php echo('Invalid username or password please check if the capslock is on ');?>");
window.location.href="index.php";
</script>
<?php
}
?>