-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfiles.php
More file actions
76 lines (72 loc) · 2.52 KB
/
files.php
File metadata and controls
76 lines (72 loc) · 2.52 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
<?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>
<!DOCTYPE html>
<html lang="en">
<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>
<div class="container">
<h2>Uploaded questionaires</h2>
<table class="table table-bordered">
<thead>
<tr>
<th>#</th>
<th>File Name</th>
<th>Uploaded on</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php
//session_start();
require_once 'api/db_connect.php';
// Check the connection
// Fetch user records from the database
$sql = "SELECT `id`, `name`, `type`, `date` FROM `files` WHERE 1";
$result = $connect->query($sql);
if ($result->num_rows > 0) {
// Loop through the result set
while ($row = $result->fetch_assoc()) {
echo "<tr>";
echo "<td>{$row['id']}</td>";
echo "<td>{$row['name']}</td>";
echo "<td>{$row['date']}</td>";
echo "<td>
<a href='api/download.php?file_name={$row['name']}' class='btn btn-primary btn-sm'>Download</a>
<a href='api/deletefile.php?file_name={$row['name']}' class='btn btn-warning btn-sm'>Remove</a>
</td>";
echo "</tr>";
}
} else {
echo "<tr><td colspan='5'>No users found</td></tr>";
}
// Close the database connection
$connect->close();
?>
</tbody>
</table>
<?php
if(isset($_SESSION['position'])){
echo '<a href="upload.php" class="btn btn-success">Upload File</a>';
}
?>
</div>
</div>
</div>
</div>
</body>
</html>