-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin_users.php
69 lines (60 loc) · 1.41 KB
/
admin_users.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
<?php
// Start session and check if the user is authenticated as admin
session_start();
if (!isset($_SESSION['admin_id']) || empty($_SESSION['admin_id'])) {
header('Location: index.php');
exit();
}
// Connect to the database
include('dbconnect.php');
// Fetch all records from the users table
$query = "SELECT * FROM users";
$result = mysqli_query($conn, $query);
?>
<!DOCTYPE html>
<html>
<head>
<title>Admin Users</title>
</head>
<body>
<nav>
<ul>
<li><a href="admin_dashboard.php">Home</a></li>
<li><a href="admin_products.php">Products</a></li>
<li><a href="admin_orders.php">Manage Orders</a></li>
<li><a href="admin_users.php">Manage Users</a></li>
<li><a href="logout.php">Logout</a></li>
</ul>
</nav>
<h1>Manage Users</h1>
<table>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
<th>Role</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php while ($row = mysqli_fetch_assoc($result)) { ?>
<tr>
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['email']; ?></td>
<td><?php echo $row['role']; ?></td>
<td>
<a href="edit_user.php?id=<?php echo $row['id']; ?>">Edit</a> |
<a href="delete_user.php?id=<?php echo $row['id']; ?>">Delete</a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</body>
</html>
<?php
// Close the database connection
mysqli_close($conn);
?>