-
Notifications
You must be signed in to change notification settings - Fork 1
/
user_management.php
93 lines (74 loc) · 2.72 KB
/
user_management.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
<?php
session_start();
if (!isset($_SESSION["email"])) {
header("location: /login.php");
}
if ($_SESSION["role"] == "user") {
header("location: /user_page.php");
}
if ($_SESSION["role"] == "manager") {
header("location: /managerpage.php");
}
$file = "./userdata.txt";
$readData = file_get_contents($file);
$allUsers = json_decode($readData, true);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>User management</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body>
<div class="container">
<div class="card my-5 p-2" style="
background: #f1f1f1;
">
<h2><?php echo $_SESSION["username"]; ?>'s only access</h2>
<div class="d-flex align-items-center justify-content-end ">
<a href="index.php" class="btn btn-info mr-2" role="button">back to Dashboard</a>
<a href="logout.php" class="btn btn-warning ">Logout</a>
</div>
</div>
<div class="card">
<div class="card-header">
<h4>User Roll Management System</h4>
</div>
<div class="card-body">
<table class="table table-bordered">
<div class="d-flex align-items-center justify-content-between pb-3">
<h4>All Users</h4>
<a href="/create.php" class="btn bg-primary text-white ">Create user</a>
</div>
<thead>
<tr style="background:#b2d5df">
<th scope="col">username</th>
<th scope="col">email</th>
<th scope="col">role</th>
<th scope="col">action</th>
</tr>
</thead>
<tbody>
<?php
foreach ($allUsers as $user) {
echo "<tr>";
echo "<td>{$user["username"]}</td>";
echo "<td>{$user["email"]}</td>";
if (empty($user["role"])): ?>
<td>N/A</td>
<?php else: ?>
<td><?php echo $user["role"]; ?></td>
<?php endif;
echo "<td><a href='edit.php?id={$user['username']}' class='btn btn-sm btn-outline-primary mr-2'>Edit</a><a href='delete.php?id={$user['username']}' class='btn btn-sm btn-outline-danger'>Delete</a></td>
</tr>";
}
?>
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>