View sourcecode

The following files exists in this folder. Click to view.

admin.php

44 lines UTF-8 Unix (LF)
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
<?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>