-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.php
88 lines (85 loc) · 3.61 KB
/
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
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
<div class="card">
<?php
include "koneksi.php";
if (!isset($_GET["subpage"])) :
$data = mysqli_query($con, "select * from user");
?>
<div class="card-body">
<div class="card-title">
<div class="posotion-relative">
<h4>Manajemen User</h4>
<div class="position-absolute top-0 end-0 mt-3 me-3">
<a href="index.php?page=user&subpage=add" class="btn btn-sm btn-primary">+</a></a>
</div>
<hr>
</div>
</div>
<div class="card-text">
<table class="table">
<tr>
<th>No</th>
<th>username</th>
<th>role</th>
<th>Aksi</th>
</tr>
<?php
if (mysqli_num_rows($data) > 0) :
$no = 1;
while ($user = mysqli_fetch_array($data)) :
?>
<tr>
<td><?= $no++ ?></td>
<td><?= $user["userName"] ?></td>
<td><?= $user["userRole"] ?></td>
<td>
<div class="btn-group">
<?php if ($user['is_active'] == 'true') : ?>
<a href="index.php?page=user&subpage=disactive&id=<?= base64_encode($user["userId"]) ?>" class="btn btn-primary">disactive</a>
<?php else : ?>
<a href="index.php?page=user&subpage=active&id=<?= base64_encode($user["userId"]) ?>" class="btn btn-success">active</a>
<?php endif; ?>
<a data-href="index.php?page=user&subpage=delete&id=<?= base64_encode($user["userId"]) ?>" class="btn btn-danger">delete</a>
</div>
</td>
</tr>
<?php endwhile;
else : ?>
<tr>
<td colspan="9" class="text-center">Tidak Ada Data</td>
</tr>
<?php endif ?>
</table>
</div>
</div>
<?php
else :
$subpage = $_GET["subpage"];
switch ($subpage) {
case 'delete':
$id = base64_decode($_GET["id"]);
$data = mysqli_query($con, "delete from user where userId = '$id'");
$_SESSION["msg"] = 'deleted!';
header("Location: index.php?page=user");
break;
case 'disactive':
$id = base64_decode($_GET["id"]);
$data = mysqli_query($con, "update user set is_active='false' where userId = '$id'");
$_SESSION["msg"] = 'success';
header("Location: index.php?page=user");
break;
case 'active':
$id = base64_decode($_GET["id"]);
$data = mysqli_query($con, "update user set is_active='true' where userId = '$id'");
$_SESSION["msg"] = 'success';
header("Location: index.php?page=user");
break;
case 'add':
include "user_form.php";
break;
default:
# code...
break;
}
endif;
?>
</div>