The following files exists in this folder. Click to view.
admin.php44 lines UTF-8 Unix (LF)
<?php
require_once "check_login.php";
require_once "database_connection.php";
$mess = isset($_GET["mess"]) ? "<p style='color:green;'>".htmlspecialchars($_GET["mess"])."</p>" : "";
$result = $conn->query("SELECT userId, username, password FROM user ORDER BY userId ASC");
$table = "<table border='1' cellpadding='6' cellspacing='0'>\n";
$table .= "<tr><th>Id</th><th>Username</th><th>Password</th><th>Delete</th><th>Edit</th></tr>\n";
while ($row = $result->fetch_assoc()) {
$id = (int)$row["userId"];
$u = htmlspecialchars($row["username"]);
$p = htmlspecialchars($row["password"]);
$table .= "<tr>\n";
$table .= "<td>{$id}</td><td>{$u}</td><td>{$p}</td>\n";
$table .= "<td><a href='deleteUser.php?userId={$id}'>Delete</a></td>\n";
$table .= "<td><a href='editUser.php?userId={$id}'>Edit</a></td>\n";
$table .= "</tr>\n";
}
$table .= "</table>\n";
?>
<!doctype html>
<html lang="sv">
<head><meta charset="utf-8"><title>Admin</title></head>
<body>
<h1>Admin</h1>
<?php echo $mess; ?>
<p>Du är inloggad som <strong><?php echo htmlspecialchars($_SESSION["username"]); ?></strong>.</p>
<p>
<a href="addUser.php">Lägg till användare</a> |
<a href="logout.php">Logga ut</a>
</p>
<h2>Användare</h2>
<?php echo $table; ?>
</body>
</html>