36952-vm/users.php
Flatlogic Bot 76d7d99142 PMS 1
2025-12-15 01:31:18 +00:00

44 lines
1.4 KiB
PHP

<?php
require_once 'session.php';
check_admin();
require_once 'db/config.php';
$db = db();
$users = $db->query("SELECT * FROM users ORDER BY username ASC")->fetchAll();
include 'templates/header.php';
?>
<div class="container mt-4">
<h2>Manage Users</h2>
<a href="add_user.php" class="btn btn-primary mb-3">Add New User</a>
<table class="table table-bordered">
<thead>
<tr>
<th>Username</th>
<th>Role</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($users as $user): ?>
<tr>
<td><?php echo htmlspecialchars($user['username']); ?></td>
<td><?php echo htmlspecialchars($user['role']); ?></td>
<td>
<a href="edit_user.php?id=<?php echo $user['id']; ?>" class="btn btn-sm btn-secondary">Edit</a>
<form action="delete_user.php" method="POST" class="d-inline" onsubmit="return confirm('Are you sure you want to delete this user?');">
<input type="hidden" name="id" value="<?php echo $user['id']; ?>">
<button type="submit" class="btn btn-sm btn-danger">Delete</button>
</form>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php include 'templates/footer.php'; ?>