-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin_logs.php
More file actions
83 lines (80 loc) · 2.2 KB
/
admin_logs.php
File metadata and controls
83 lines (80 loc) · 2.2 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
session_start();
if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'admin') {
header("Location: Practical_13_Login.html");
exit();
}
$conn = new mysqli("localhost", "root", "Heleninh@2022", "HAC_Services");
$sql = "SELECT logs.id, users.name, users.role, logs.action, logs.timestamp
FROM logs
JOIN users ON logs.user_id = users.id
ORDER BY logs.timestamp DESC
LIMIT 50";
$result = $conn->query($sql);
?>
<!DOCTYPE html>
<html>
<head>
<title>Activity Logs | Admin Dashboard</title>
<style>
body {
font-family: Arial, sans-serif;
background: #f3e5f5;
margin: 0;
padding: 0;
}
.container {
max-width: 800px;
margin: 50px auto;
background: white;
padding: 30px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
h2 {
text-align: center;
color: #6a1b9a;
margin-bottom: 20px;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 10px;
}
th, td {
padding: 12px;
border-bottom: 1px solid #ddd;
text-align: left;
}
th {
background-color: #ce93d8;
color: white;
}
tr:hover {
background-color: #f3e5f5;
}
</style>
</head>
<body>
<div class="container">
<h2>User Activity Logs</h2>
<table>
<tr>
<th>User</th>
<th>Role</th>
<th>Action</th>
<th>Timestamp</th>
</tr>
<?php while ($row = $result->fetch_assoc()): ?>
<tr>
<td><?= htmlspecialchars($row['name']) ?></td>
<td><?= htmlspecialchars($row['role']) ?></td>
<td><?= htmlspecialchars($row['action']) ?></td>
<td><?= $row['timestamp'] ?></td>
</tr>
<?php endwhile; ?>
</table>
</div>
</body>
</html>
<?php $conn->close(); ?>