-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.php
More file actions
64 lines (54 loc) · 1.75 KB
/
admin.php
File metadata and controls
64 lines (54 loc) · 1.75 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
53
54
55
56
57
58
59
60
61
62
63
64
<?php
include 'auth.php';
include 'db.php';
//admin@mindmatrix.io pass:- admin123
// Ensure only admins can access
if ($_SESSION['role'] !== 'admin') {
echo "<h1>Access Denied!</h1>";
exit();
}
// Fetch all users
$users = $conn->query("SELECT id, name, email, role, created_at FROM users");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Panel</title>
<link rel="stylesheet" href="assets/css/admin.css">
</head>
<body>
<div class="admin-container">
<h1>Admin Panel</h1>
<p>Manage Users & System Logs</p>
<h3><a href="admin_logs.php">📊 View System Logs</a></h3>
<table border="1">
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
<th>Role</th>
<th>Joined</th>
<th>Action</th>
</tr>
<?php while ($user = $users->fetch_assoc()) { ?>
<tr>
<td><?php echo $user['id']; ?></td>
<td><?php echo $user['name']; ?></td>
<td><?php echo $user['email']; ?></td>
<td><?php echo ucfirst($user['role']); ?></td>
<td><?php echo $user['created_at']; ?></td>
<td>
<?php if ($user['role'] !== 'admin') { ?>
<a href="php/delete_user.php?id=<?php echo $user['id']; ?>" onclick="return confirm('Are you sure?')">🗑 Delete</a>
<?php } else { echo "Admin"; } ?>
</td>
</tr>
<?php } ?>
</table>
<br>
<a href="logout.php">🚪 Logout</a>
</div>
</body>
</html>