-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathauth.php
57 lines (49 loc) · 1.71 KB
/
auth.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
<?php
session_start();
if(isset($_SESSION['userid'])==false)
{
header('location:/project/index.html');
}
include("config.php");
if(isset($_POST['login']))
{
$selected_val = $_POST['department'];
$myusername = mysqli_real_escape_string($db,$_POST['ID']);
$mypassword = mysqli_real_escape_string($db,$_POST['PASSWORD']);
$_SESSION['userid'] = $myusername;
if((!empty($myusername))&&(!empty($mypassword)))
{
if($selected_val=="SECURITY")
{
$sql = "SELECT SID_NO FROM SECURITY WHERE SID_NO = '$myusername' and PASSWORD = '$mypassword'";
$result = mysqli_query($db,$sql);
$row = mysqli_fetch_array($result,MYSQLI_ASSOC);
$active = $row['active'];
$count = mysqli_num_rows($result);
if($count == 1)
{
header("location:/project/new.php");
}
else
{
header("location:/project/error.html");
}
}
if($selected_val=="OFFICE")
{ $sql = "SELECT ID FROM OFFICE WHERE ID = '$myusername' and PASSWORD = '$mypassword'";
$result = mysqli_query($db,$sql);
$row = mysqli_fetch_array($result,MYSQLI_ASSOC);
$active = $row['active'];
$count = mysqli_num_rows($result);
if($count == 1)
{
header("location:/project/office.php");
}
else
{
header("location:/project/error.html");
}
}
}
}
?>