Repository navigation
Expand file tree
/
Copy pathadmin.php
More file actions
52 lines (44 loc) · 1.92 KB
/
Copy pathadmin.php
File metadata and controls
52 lines (44 loc) · 1.92 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
51
52
<?php
session_start();
require 'db.php';
$error = "";
if (isset($_POST['admin_login'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$sql = "SELECT * FROM users WHERE Username = '$username' AND Password = '$password' AND Role = 'Admin'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
$_SESSION['admin_id'] = $row['User_ID'];
$_SESSION['admin_name'] = $row['Name'];
header("Location: admin_dashboard.php");
exit();
} else {
$error = "Invalid Admin Username or Password!";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Admin Login</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header style="padding: 20px 50px; background-color: #000;">
<a href="index.php" style="text-decoration: none !important;"><span style="font-size: 28px; font-weight: bold; color: white; letter-spacing: 1px;">Smart<span style="color: #3b82f6;">Gym</span></span></a>
</header>
<div style="min-height: calc(100vh - 78px); padding: 80px 20px; background-color: #1e1e2d; box-sizing: border-box; display: flex; flex-direction: column; align-items: center;">
<div style="max-width: 400px; width: 100%;">
<h2 style="margin-top: 0; color: white;">Admin Portal</h2>
<?php if ($error != "") echo "<div class='error-box'>$error</div>"; ?>
<form action="admin.php" method="POST">
<input type="text" name="username" placeholder="Admin Username" required>
<input type="password" name="password" placeholder="Password" required>
<button type="submit" name="admin_login" style="width: 100%; background-color: red;">SECURE LOGIN</button>
</form>
</div>
</div>
</body>
</html>