-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin_view_users.php
More file actions
37 lines (36 loc) · 1.16 KB
/
admin_view_users.php
File metadata and controls
37 lines (36 loc) · 1.16 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
<?php
session_start();
if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'admin') {
header("Location: Practical_13_Login.html");
exit();
}
$conn = new mysqli("localhost", "root", "Heleninh@2022", "HAC_Services");
$result = $conn->query("SELECT id, name, email, role FROM users");
?>
<!DOCTYPE html>
<html>
<head>
<title>All Users</title>
<style>
table { width: 80%; margin: auto; border-collapse: collapse; }
th, td { padding: 10px; border: 1px solid #ccc; text-align: left; }
th { background: #1976d2; color: white; }
tr:nth-child(even) { background: #f1f1f1; }
</style>
</head>
<body>
<h2 style="text-align:center;">All Registered Users</h2>
<table>
<tr><th>ID</th><th>Name</th><th>Email</th><th>Role</th></tr>
<?php while($row = $result->fetch_assoc()): ?>
<tr>
<td><?= $row['id'] ?></td>
<td><?= htmlspecialchars($row['name']) ?></td>
<td><?= htmlspecialchars($row['email']) ?></td>
<td><?= $row['role'] ?></td>
</tr>
<?php endwhile; ?>
</table>
</body>
</html>
<?php $conn->close(); ?>