-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblocked_user.php
58 lines (49 loc) · 2.37 KB
/
blocked_user.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
<?php
include("components/db/db_connection.php");
include("components/header.php");
include("components/navbar.php");
// Check if the current user is an admin
$is_admin = $_SESSION['is_admin'];
// Handle the form submission
if (isset($_POST["update"])) {
$user_id = $_POST['user_id'];
// Update the user's is_blocked field to 0
$result = mysqli_query($connection, "UPDATE users SET is_blocked = 0 WHERE id = $user_id");
}
?>
<div class="container mx-auto py-8">
<div class="flex justify-between items-center mb-8">
<h1 class="text-2xl font-bold">Pengguna Disekat</h1>
<a href="dashboard_admin.php" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">Paparan </a>
</div>
<table class="w-full border-collapse">
<thead>
<tr class="bg-gray-100">
<th class="border text-left px-8 py-4">#</th>
<th class="border text-left px-8 py-4">Nama</th>
<th class="border text-left px-8 py-4">Nombor IC</th>
<th class="border text-left px-8 py-4">Disekat</th>
<th class="border text-left px-8 py-4">Tindakan</th>
</tr>
</thead>
<tbody>
<?php
$data = mysqli_query($connection, "SELECT * FROM users WHERE is_blocked = 1");
while ($info = mysqli_fetch_array($data)) { ?>
<tr>
<td class="border px-4 py-2"><?php echo $info['id']; ?></td>
<td class="border px-4 py-2"><?php echo $info['name']; ?></td>
<td class="border px-4 py-2"><?php echo $info['ic']; ?></td>
<td class="border px-4 py-2"><?php echo $info['is_blocked'] ? '<span class="bg-red-500 text-white px-2 rounded">Disekat</span>' : '<span class="bg-green-500 text-white px-2 rounded">Active</span>'; ?></td>
<td class="border px-4 py-2">
<form method="post" class="inline">
<input type="hidden" name="user_id" value="<?php echo $info['id']; ?>">
<button type="submit" name="update" class="bg-green-500 hover:bg-green-700 text-white font-bold py-2 px-4 rounded">Nyahsekat</button>
</form>
</td>
</tr>
</tbody>
<?php } ?>
</table>
</div>
<?php include("components/footer.php"); ?>