-
Notifications
You must be signed in to change notification settings - Fork 2
/
displayAllUsers.php
116 lines (90 loc) · 3.13 KB
/
displayAllUsers.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset = "utf-8">
<title>Verify Admin Users</title>
<!-- 1. Include style -->
<link href="_css/atc-style-button-icon.css" rel="stylesheet" type="text/css">
<link href="_css/atc-style-menu-wb.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="_css/styles.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
</head>
<body>
<div id="container">
<div id="header">
<header role = "banner">
<?php
$subtitle = "Manage Users";
include('_php/banner.php');
?>
</header>
</div>
<div id="body">
<main role = "main">
<!-- MANAGE ADMIN USERS CONTENT -->
<section id="favourites">
<br>
<table style = "width: 100%" class = "adminTableText">
<!-- tr is the row -->
<!-- table cell is td -->
<!-- th is the header -->
<tr class = "adminTableHeader">
<th> Username </th>
<th> Admin Status </th>
<th> Toggle Admin Status </th>
</tr>
<?php
require_once('_php/config.php');
// Show admins
$sql = "SELECT * FROM users WHERE Admin = 1 ORDER BY Username";
$result = $connection->query($sql);
if (!$result) {
echo "could not load users";
} else {
foreach ($result as $row) {
echo '<tr>';
echo ' <td>' . $row['Username'] . '</td>';
echo ' <td> Admin </td>';
echo ' <td><form action="_php/toggleAdmin.php" method="post">';
echo ' <input type="hidden" name="UserID" value="' . $row['UserID'] . '">';
echo ' <button type="submit" class="yesBtn">Remove Admin</button></form></td>';
echo '</tr>';
}
}
// Show regular users
$sql = "SELECT * FROM users WHERE Admin = 0 ORDER BY Username";
$result = $connection->query($sql);
if (!$result) {
echo "could not load users";
} else {
foreach ($result as $row) {
echo '<tr>';
echo ' <td>' . $row['Username'] . '</td>';
echo ' <td> Non-Admin </td>';
echo ' <td><form action="_php/toggleAdmin.php" method="post">';
echo ' <input type="hidden" name="UserID" value="' . $row['UserID'] . '">';
echo ' <button type="submit" class="yesBtn">Make Admin</button></form></td>';
echo '</tr>';
}
}
?>
</table>
</section>
</main>
</div>
<div id="footer">
<!--Footer-->
<footer id = "pageFooter">
<ul id = "footerNav">
<li class="footerLink"><a href="help.php"><div class="linkText">Terms and Conditions</div></a></li>
<li class="footerLink"><a href="help.php"><div class="linkText">Contact</div></a></li>
<li class="footerLink"><a href="help.php"><div class="linkText">Copyright</div></a></li>
</ul>
</footer>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script src = "_scripts/script.js"></script>
</body>
</html>