-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.php
83 lines (75 loc) · 2.66 KB
/
admin.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
<?php
$login=false;
$showError=false;
if($_SERVER["REQUEST_METHOD"] == "POST")
{
include('partials/dbcon.php');
$username=$_POST["username"];
$password=$_POST["password"];
$sql="SELECT * FROM `admin` WHERE admin_name='$username' AND admin_password='$password'";
$result=mysqli_query($con,$sql);
$num=mysqli_num_rows($result);
if ($num == 1) {
$login=true;
session_start();
$_SESSION['loggedin'] = true;
$_SESSION['username'] = $username;
header("location: admin/dashboard.php");
// echo "You are loggedin";
} else {
$showError="Invalid credentials";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<link rel="stylesheet" href="style.css">
<title>Admin Login</title>
</head>
<body>
<header>
<?php
include('partials/nav.php');
?>
</header>
<?php
if($login){
echo '<div class="alert alert-success alert-dismissible fade show" role="alert">
<strong>Success!</strong>You are logged in
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>';
}
if($showError){
echo '<div class="alert alert-danger alert-dismissible fade show" role="alert">
<strong>Error!</strong>'. $showError.'
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>';
}
?>
<main>
<section id="login">
<h1>Admin Login</h1>
<form action="/projectself/admin.php" method="post">
<div class="form-group">
<label for="username">Admin Username</label>
<input type="text" id="username" name="username" required>
</div>
<div class="form-group">
<label for="password">Admin Password</label>
<input type="password" id="password" name="password" required>
</div>
<button type="submit" class="btn">Login</button>
</form>
</section>
</main>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script>
<?php
include('partials/footer.php');
?>
</body>
</html>