-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathManageUsers.php
30 lines (29 loc) · 1.01 KB
/
ManageUsers.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
<?php
include "database.php";
include "functions.php";
include "header.php"; # Has other includes as well as log-out detection, and favicon. NB Has "<html><head>" for favicon link!
echo "</head><body>";
PageHeader("Users");
$db = DatabaseInit();
ShowUsers($db);
echo "<br>";
echo "<button class=\"button\" type=\"button\" onclick=\"window.location.href='/vesta/AddNewUser.php'\">Add new user</button><br><br>";
PageFooter();
echo "</body></html>";
function ShowUsers($db)
{
$sth = $db->prepare("SELECT * FROM Users");
$sth->execute();
$index = 0;
while ($row = $sth->fetch()) {
$names[$index] = $row['name'];
$ids[$index] = $row['id'];
$index++;
}
for ($userIdx = 0; $userIdx < $index; $userIdx++) {
echo "<form action=\"/vesta/DeleteUser.php/?userId=", $ids[$userIdx], "\" method=\"post\">";
echo "<input type=\"text\" size=\"100\" name=\"userName\" value=\"", $names[$userIdx], "\">";
echo "<input type=\"submit\" value=\"Remove\"></form>";
}
}
?>