-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmainAuth.php
152 lines (114 loc) · 5.39 KB
/
mainAuth.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<!DOCTYPE html>
<html>
<head>
<title>Main Page</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
</head>
<body>
<button id="showEmp">Employee Table</button>
<button id="showAtt">Attendance Table</button>
<button id="showSal">Salary Table</button>
<?php
if(isset($_POST['username'])){
$user = $_POST["username"];
}else{
$user = '';
}
if(isset($_POST['password'])){
$pass = $_POST["password"];
}else{
$pass = '';
}
?>
<?php require("connection.php") ?>
<div id="empTable" style="display:none">
<?php $sql_statement = " SELECT username ,Branch_name FROM admin WHERE username = '".$user."' AND password = '".$pass."' ";
$result = mysqli_query($db,$sql_statement);
if(!$result){
$outputDisplay .= "<br><font color=red>mysqli No: ".mysqli_errno($db);
$outputDisplay .= "<br>mysqli Error: ".mysqli_error();
$outputDisplay .= "<br>SQL Statement: ".$sql_statement;
$outputDisplay .= "<br>mysqli Affected Rows: ".mysqli_affected_rows()."</font><br>";
}else{
$numresults = mysqli_num_rows($result);
if($numresults == 0){
echo "<script> alert(\"Invalid Username OR Password!!!\");window.location.href='index.php'</script>";
}else{
echo "<h1> Welcome " .ucfirst($user)."</h1>";
$row = mysqli_fetch_array($result);
$branch = $row['Branch_name'];
echo "<h2> Admin Branch : ".ucfirst($branch);
require("selectFromEmployee.php");
// require("selectAttendance.php");
//require("selectSalary.php");
}
}
?>
</div>
<div id="attendanceTable" style="display:none">
<?php $sql_statement = " SELECT username ,Branch_name FROM admin WHERE username = '".$user."' AND password = '".$pass."' ";
$result = mysqli_query($db,$sql_statement);
if(!$result){
$outputDisplay .= "<br><font color=red>mysqli No: ".mysqli_errno($db);
$outputDisplay .= "<br>mysqli Error: ".mysqli_error();
$outputDisplay .= "<br>SQL Statement: ".$sql_statement;
$outputDisplay .= "<br>mysqli Affected Rows: ".mysqli_affected_rows()."</font><br>";
}else{
$numresults = mysqli_num_rows($result);
if($numresults == 0){
echo "<script> alert(\"Invalid Username OR Password!!!\");window.location.href='index.php'</script>";
}else{
echo "<h1> Welcome " .ucfirst($user)."</h1>";
$row = mysqli_fetch_array($result);
$branch = $row['Branch_name'];
echo "<h2> Admin Branch : ".ucfirst($branch);
require("selectAttendance.php");
}
}
?>
</div>
<div id="salaryTable" style="display:none">
<?php $sql_statement = " SELECT username ,Branch_name FROM admin WHERE username = '".$user."' AND password = '".$pass."' ";
$result = mysqli_query($db,$sql_statement);
if(!$result){
$outputDisplay .= "<br><font color=red>mysqli No: ".mysqli_errno($db);
$outputDisplay .= "<br>mysqli Error: ".mysqli_error();
$outputDisplay .= "<br>SQL Statement: ".$sql_statement;
$outputDisplay .= "<br>mysqli Affected Rows: ".mysqli_affected_rows()."</font><br>";
}else{
$numresults = mysqli_num_rows($result);
if($numresults == 0){
echo "<script> alert(\"Invalid Username OR Password!!!\");window.location.href='index.php'</script>";
}else{
echo "<h1> Welcome " .ucfirst($user)."</h1>";
$row = mysqli_fetch_array($result);
$branch = $row['Branch_name'];
echo "<h2> Admin Branch : ".ucfirst($branch);
require("selectSalary.php");
}
}
?>
</div>
<form action="index.php">
<input type="submit" value="Log Out"></input>
</form>
<script>
$(function(){
$('button#showEmp').on('click',function(){
$('#empTable').toggle();
});
});
$(function(){
$('button#showAtt').on('click',function(){
$('#attendanceTable').toggle();
});
});
$(function(){
$('button#showSal').on('click',function(){
$('#salaryTable').toggle();
});
});
</script>
</body>
</html>