-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
179 lines (140 loc) · 4.37 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
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<?php
if(isset($_POST['login']))
{
//start of try block
try{
//checking empty fields
if(empty($_POST['username'])){
throw new Exception("Username is required!");
}
if(empty($_POST['password'])){
throw new Exception("Password is required!");
}
//establishing connection with db and things
include ('connect.php');
//checking login info into database
$row=0;
$result=mysql_query("select * from admininfo where username='$_POST[username]' and password='$_POST[password]' and type='$_POST[type]'");
$row=mysql_num_rows($result);
if($row>0 && $_POST["type"] == 'teacher'){
session_start();
$_SESSION['name']="oasis";
header('location: teacher/index.php');
}
else if($row>0 && $_POST["type"] == 'student'){
session_start();
$_SESSION['name']="oasis";
header('location: student/index.php');
}
else if($row>0 && $_POST["type"] == 'admin'){
session_start();
$_SESSION['name']="oasis";
header('location: admin/index.php');
}
else{
throw new Exception("Username,Password or Role is wrong, try again!");
header('location: login.php');
}
}
//end of try block
catch(Exception $e){
$error_msg=$e->getMessage();
}
//end of try-catch
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Online Attendance Management System 1.0</title>
<link rel="stylesheet" type="text/css" href="css/main.css">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" >
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" >
<link rel="stylesheet" href="styles.css" >
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<center>
<header>
<h1>Online Attendance Management System 1.0</h1>
</header>
<h1>Login</h1>
<?php
//printing error message
if(isset($error_msg))
{
echo $error_msg;
}
?>
<!-- Old Version -->
<!--
<form action="" method="post">
<table>
<tr>
<td>Username </td>
<td><input type="text" name="username"></input></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password"></input></td>
</tr>
<tr>
<td>Role</td>
<td>
<select name="type">
<option name="teacher" value="teacher">Teacher</option>
<option name="student" value="student">Student</option>
<option name="admin" value="admin">Admin</option>
</select>
</td>
</tr>
<tr><td><br></td></tr>
<tr>
<td><button><input type="submit" name="login" value="Login"></input></button></td>
<td><button><input type="reset" name="reset" value="Reset"></button></td>
</tr>
</table>
</form>
-->
<div class="content">
<div class="row">
<form method="post" class="form-horizontal col-md-6 col-md-offset-3">
<div class="form-group">
<label for="input1" class="col-sm-3 control-label">Username</label>
<div class="col-sm-7">
<input type="text" name="username" class="form-control" id="input1" placeholder="your usrename" />
</div>
</div>
<div class="form-group">
<label for="input1" class="col-sm-3 control-label">Password</label>
<div class="col-sm-7">
<input type="password" name="password" class="form-control" id="input1" placeholder="your password" />
</div>
</div>
<div class="form-group" class="radio">
<label for="input1" class="col-sm-3 control-label">Role</label>
<div class="col-sm-7">
<label>
<input type="radio" name="type" id="optionsRadios1" value="student" checked> Student
</label>
<label>
<input type="radio" name="type" id="optionsRadios1" value="teacher"> Teacher
</label>
<label>
<input type="radio" name="type" id="optionsRadios1" value="admin"> Admin
</label>
</div>
</div>
<input type="submit" class="btn btn-primary col-md-3 col-md-offset-7" value="Login" name="login" />
</form>
</div>
</div>
<br><br>
<p><strong>Have forgot your password? <a href="reset.php">Reset here.</a></strong></p>
<p><strong>If you don't have any account, <a href="signup.php">Signup</a> here</strong></p>
</center>
</body>
</html>