-
Notifications
You must be signed in to change notification settings - Fork 2
/
admin_login.php
78 lines (75 loc) · 2.26 KB
/
admin_login.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
<?php
require_once "config.php";
// mysql_select_db();
session_name("admin");
session_start();
// Check if the user is already logged in, if yes then redirect him to welcome page
if(isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true){
header("location: admin_access.php");
exit;
}
if (isset($_POST['submit'])){
$uname=$_POST['uname'];
$password=$_POST['password'];
$id=$_POST['id'];
if($id==14){
$query="select * from counsellor where id='$id' and cname='$uname' and password='$password'" ;
}
else{
echo "You've entered wrong credentials admin,";
echo " please enter correct credentials";
exit();
}
$result=mysqli_query($conn,$query);
if(mysqli_num_rows($result)==1){
echo "You have sucessfully logged in";
session_start();
$_SESSION["loggedin"] = true;
$_SESSION["uname"] = $uname;
header("location: admin_access.php");
exit();
}
else{
echo "You've entered wrong credentials ";
echo ".Please enter correct credentials";
exit();
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Admin login</title>
<link type="text/css" rel="stylesheet" href="stylesheet.css">
</head>
<body>
<div style="text-align:center">
<form action="#" method="post">
<table align='center' style="font-weight:bold;">
<tr>
<td><h1 style='text-align:center'>Admin login</h1></td>
</tr>
<tr>
<td align='right'>
<label for="login_id">id:</label>
<input type='number' name="id" id="login_id" required></td>
</tr>
<tr>
<td align='right'>
<label for="login_staff">name:</label>
<input type='text' name="uname" id="login_staff" required></td>
</tr>
<tr>
<td>
<label for="password_staff">Password:</label>
<input type='password' name="password" id="password_staff" required></td>
</tr>
<tr>
<td align='center'><br>
<input type="submit" name="submit" class='button' value="Login"/>
</td>
</tr>
</table>
</form>
</div>
</body>