-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
120 lines (102 loc) · 4.03 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
<?php
//require 'connection.php';
session_start();
if(isset($_SESSION['admin_id'])){
$admin_id = $_SESSION['admin_id'];
if($admin_id!=NULL){
header('Location: admin/adminhome.php');
}
}
if(isset($_POST['loginbtn'])){
require 'admin/connection.php';
$password = md5($_POST['password']);
$sql = "Select * FROM registration_table WHERE user_name = '$_POST[userName]' AND pass ='$password'";
if(mysqli_query($conn, $sql)){
$row = mysqli_query($conn, $sql);
$result = mysqli_fetch_assoc($row);
$s = $result['status'];
if($s == 2){
if($result){
session_start();
$_SESSION['admin_id'] = $result['id'];
$_SESSION['admin_name'] = $result['name'];
header('Location: admin/adminhome.php');
} else {
echo 'Invalid UserName and Password';
}
}
if($s == 1){
if($result){
session_start();
$_SESSION['userId'] = $result['id'];
$_SESSION['userName'] = $result['name'];
header('Location: users/userhome.php');
} else {
echo 'Invalid UserName and Password';
}
}
if($s == 3){
if($result){
session_start();
$_SESSION['quesSetId'] = $result['id'];
$_SESSION['quesSetName'] = $result['name'];
header('Location: questionSetter/home.php');
} else {
echo 'Invalid UserName and Password';
}
}
} else {
echo 'Error';
}
}
?>
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Fonts -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/mystyle.css">
<title>Online exam</title>
</head>
<body>
<?php include 'includes/navber.php'; ?>
<main class="login-form mt-5">
<div class="cotainer">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header mch">Login Home</div>
<div class="card-body">
<form action="" method="POST" class="mt-5 mb-5">
<div class="form-group row">
<label for="userName" class="col-md-4 col-form-label text-md-right">User Name</label>
<div class="col-md-6">
<input type="text" id="userName" class="form-control" name="userName" required autofocus>
</div>
</div>
<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">Password</label>
<div class="col-md-6">
<input type="password" id="password" class="form-control" name="password" required>
</div>
</div>
<div class="col-md-6 offset-md-4">
<button type="submit" class="btn btn-danger" name="loginbtn">
Login
</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</body>
</html>