-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
223 lines (216 loc) · 6.77 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<?php
include("header.php");
if(isset($_SESSION[regno]))
{
echo "<script>window.location=myaccount.php;</script>";
}
if(isset($_SESSION[userid]))
{
echo "<script>window.location=dashboard.php;</script>";
}
if(isset($_SESSION[examinerid]))
{
echo "<script>window.location=examinerpanel.php;</script>";
}
if(isset($_POST[submitstudent]))
{
$sqlstudent ="SELECT * FROM students WHERE regno=$_POST[studentusername] AND password=$_POST[studentpassword]";
$stquery = mysqli_query($con,$sqlstudent);
if(mysqli_num_rows($stquery) == 1)
{
$sqlupd = "UPDATE students SET lastlogin=$dttim WHERE regno=$_POST[studentusername]";
mysqli_query($con,$sqlupd);
$_SESSION[regno] = $_POST[studentusername];
echo "<script>window.location=myaccount.php;</script>";
}
else
{
$errmsg1 = "<br><b><font color=red>Failed to login.</font></b>";
}
}
if(isset($_POST[submitteacher]))
{
$sqlteacher ="SELECT * FROM users WHERE username=$_POST[teacherusername] AND password=$_POST[teacherpassword] AND usertype=Examiner";
$tequery =mysqli_query($con,$sqlteacher);
if(mysqli_num_rows($tequery) == 1)
{
$rs = mysqli_fetch_array($tequery);
$sqlupd = "UPDATE users SET lastlogin=$dttim WHERE userid=$rs[userid]";
mysqli_query($con,$sqlupd);
echo mysqli_error($con);
$errmsg2 = "<br><b><font color=green>Employee logged in successfully..</font></b>";
$_SESSION[examinerid] = $rs[userid];
$_SESSION[usertype] = $rs[usertype];
$_SESSION[courseid] = $rs[courseid];
echo "<script>window.location=examinerpanel.php;</script>";
}
else
{
$errmsg2 = "<br><b><font color=red>Failed to login..</font></b>";
}
}
if(isset($_POST[submitadmin]))
{
$sqladmin ="SELECT * FROM users WHERE username=$_POST[adminusername] AND password=$_POST[adminpassword] AND usertype=Administrator";
$adquery =mysqli_query($con,$sqladmin);
if(mysqli_num_rows($adquery) == 1)
{
$rs = mysqli_fetch_array($adquery);
$sqlupd = "UPDATE users SET lastlogin=$dttim WHERE userid=$rs[userid]";
mysqli_query($con,$sqlupd);
echo mysqli_error($con);
$errmsg3 = "<br><b><font color=green>Administrator logged in successfully..</font></b>";
$_SESSION[userid] = $rs[userid];
$_SESSION[usertype] = $rs[usertype];
echo "<script>window.location=dashboard.php;</script>";
}
else
{
$errmsg3 = "<br><b><font color=red>Failed to login...</font></b>";
}
}
?>
<div class="slider_top">
<div class="header_text">
<div class="gallery">
<div id="slider">
<ul>
<li> <img src="images/online.png" alt="screen 1" width="960" height="323" border="0" class="screen" /> </li>
<li> <img src="images/online-exam-940x196.jpg" alt="screen 1" width="960" height="320" border="0" class="screen" /> </li>
<li> <img src="images/gal_1bg.jpg" alt="screen 1" width="960" height="320" border="0" class="screen" /> </li>
</ul>
</div>
</div>
<div class="clr"></div>
</div>
</div>
<div class="clr"></div>
<div class="body_resize">
<div class="clr"></div>
<div class="body">
<div class="right">
<h2 class="Welco">Administrator login</h2>
<p> <strong>Please enter User name and password. <?php echo $errmsg3; ?></strong><br />
<form name="formadministrator" method="post" action="" onsubmit="return validation()" >
<table>
<tr>
<th>Username</th>
<td><input type=text id="adminusername" name="adminusername" class="text" placeholder="Enter Username" /></td>
</tr>
<tr>
<th>Password</th>
<td><input type="password" id="adminpassword" name="adminpassword" class="text" placeholder="Enter password"/></td>
</tr>
<tr>
<th colspan="2"> <input type="submit" id="submitadmin" name="submitadmin" class="text" value="Login"/></th>
</tr>
</table>
</form>
</p>
<pre> </pre>
</div>
<div class="right">
<h2 class="Welco">Examiner login</h2>
<p><strong>Please enter User name and password. <?php echo $errmsg2; ?> </strong><br />
<form method="post" action="" name="formexaminer"onsubmit="return validation1()" >
<table>
<tr>
<th>Username</th>
<td><input type=text id="teacherusername" name="teacherusername" class="text" placeholder="Enter User Name" /></td>
</tr>
<tr>
<th>Password</th>
<td><input type="password" id="teacherpassword" name="teacherpassword" class="text" placeholder="Enter password" /></td>
</tr>
<tr>
<th colspan="2"> <input type="submit" id="submitteacher" name="submitteacher" class="text" value="Login" /></th>
</tr>
</table>
</form>
</div>
<div class="right">
<h2 class="Welco"> Students login</h2>
<div class="clr"></div>
<p><strong>Please enter User name and password. <?php echo $errmsg1; ?> </strong><br />
<form method="post" action="" name="formstudent" onsubmit="return validation2()">
<table>
<tr>
<th>Registration No.</th>
<td><input type=text id="studentusername" name="studentusername" class="text" placeholder="Enter Registration No." /></td>
</tr>
<tr>
<th>Password</th>
<td><input type="password" id="studentpassword" name="studentpassword" class="text" placeholder="Enter password" /></td>
</tr>
<tr>
<th colspan="2"> <input type="submit" id="submitstudent" name="submitstudent" class="text" value="Login" /></th>
</tr>
</table>
</form>
</p>
</div>
<div class="clr"></div>
</div>
</div>
<?php
include("footer.php");
?>
<script type="application/javascript">
function validation()
{
if(formadministrator.adminusername.value=="")
{
alert("Please enter user name...");
formadministrator.adminusername.focus();
return false;
}
else if(formadministrator.adminpassword.value=="")
{
alert("Please enter valid Password..");
formadministrator.adminpassword.focus();
return false;
}
else
{
return true;
}
}
function validation1()
{
if(formexaminer.teacherusername.value=="")
{
alert("Please enter user name...");
formexaminer.teacherusername.focus();
return false;
}
else if(formexaminer.teacherpassword.value=="")
{
alert("Please enter valid Password..");
formexaminer.teacherpassword.focus();
return false;
}
else
{
return true;
}
}
function validation2()
{
if(formstudent.studentusername.value=="")
{
alert("Please enter Registration No..");
formstudent.studentusername.focus();
return false;
}
else if(formstudent.studentpassword.value=="")
{
alert("Please enter valid Password..");
formstudent.studentpassword.focus();
return false;
}
else
{
return true;
}
}
</script>