-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadmin.php
More file actions
50 lines (48 loc) · 1.77 KB
/
admin.php
File metadata and controls
50 lines (48 loc) · 1.77 KB
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
<?php include 'includes/header.php'; ?>
<?php include 'config/config.php'; ?>
<?php include 'lib/Database.php'; ?>
<?php
//Grab Post Data
$db = new Database();
if(isset($_POST['submit'])){
$username = $_POST['username'];
$password = $_POST['password'];
//validation check
if($username == '' || $password == ''){
echo "Please Fill the details";
}
else{
//query
$query = "SELECT * FROM user WHERE email = '$username' AND password = '$password' AND user_type = 2";
$result = $db->select($query);
if($result){
$row = $result->fetch_assoc();
$count = $result->num_rows;
if($count == 1){
$_SESSION['user'] = $row['email'];
$_SESSION['id'] = $row['id'];
$_SESSION['user_type'] = $row['user_type'];
header('Location: add.php');
}
}
else{
echo "Authentication Failed";
}
}
}
?>
<div class="jumbotron">
<h2 class="text-center">Admin Panel</h2>
</div>
<div class="wrapper">
<form action="admin.php" method="post" class="form-signin">
<h2 class="form-signin-heading">Please Login</h2>
<input type="text" class="form-control" name="username" placeholder="Email Address" required="" autofocus="" />
<input type="password" class="form-control" name="password" placeholder="Password" required=""/>
<label class="checkbox">
<input type="checkbox" value="remember-me" id="rememberMe" name="rememberMe"> Remember me
</label>
<input class="btn btn-lg btn-primary btn-block" type="submit" name="submit" value="Login"/>
</form>
</div>
<?php include 'includes/footer.php';?>