<?php
session_start();
if (!isset($_SESSION['admin_id'])) { header("Location: login.php"); exit(); }
include '../include/config.php';

$users = $conn->query("SELECT user_id, username, email, role, created_at FROM users ORDER BY created_at DESC");
?>
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>Manage Users</title><link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"></head>
<body><div class="container mt-4"><h2>System Users</h2><table class="table table-bordered"><?php while($u=$users->fetch_assoc()): ?><tr><td><?= $u['username'] ?></td><td><?= $u['email'] ?></td><td><?= $u['role'] ?></td><td><?= $u['created_at'] ?></td></tr><?php endwhile; ?></table><a href="dashboard.php" class="btn btn-secondary">Back</a></div></body>
</html>