-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusers.php
More file actions
67 lines (65 loc) · 2.34 KB
/
users.php
File metadata and controls
67 lines (65 loc) · 2.34 KB
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
<?php
session_start();
if (isset($_SESSION['position'])) {
if($_SESSION['position']=='ADMIN') {
include 'navbar.html';
}else{
echo "<meta http-equiv='refresh' content='0;url=login.php'>";
}
}else{
echo "<meta http-equiv='refresh' content='0;url=login.php'>";
}
?>
<!DOCTYPE html>
<html>
<head>
<title>User Management</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<div class="container">
<h4 class="my-4">System Users</h4>
<table class="table table-bordered">
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
<th>Position</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php
require_once 'api/db_connect.php';
// Check the connection
// Fetch user records from the database
$sql = "SELECT * FROM users";
$result = $connect->query($sql);
if ($result->num_rows > 0) {
// Loop through the result set
while ($row = $result->fetch_assoc()) {
echo "<tr>";
echo "<td>{$row['firstname']}</td>";
echo "<td>{$row['lastname']}</td>";
echo "<td>{$row['username']}</td>";
echo "<td>{$row['position']}</td>";
echo "<td>
<a href='edit.php?username={$row['username']}' class='btn btn-primary btn-sm'>Edit</a>
<a href='delete.php?username={$row['username']}' class='btn btn-danger btn-sm'>Delete</a>
</td>";
echo "</tr>";
}
} else {
echo "<tr><td colspan='5'>No users found</td></tr>";
}
// Close the database connection
$connect->close();
?>
</tbody>
</table>
<a href="registration.php" class="btn btn-success">Add User</a>
</div>
</body>
</html>