forked from DanyPDev/pandemic-progression-system
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathallUsers.php
More file actions
104 lines (86 loc) · 3.37 KB
/
allUsers.php
File metadata and controls
104 lines (86 loc) · 3.37 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php require_once './components/database.inc.php';
require_once './components/functions.inc.php';
session_start();
if(isset($_POST['delete'])){
$id_to_delete = mysqli_real_escape_string($conn, $_POST['userID']);
$sql = "DELETE FROM User WHERE userID = $id_to_delete;";
if(mysqli_query($conn, $sql)){
header('location: allUsers.php?userDelete=true');
echo '<script>alert("User Deleted from Database")</script>'; //https://www.geeksforgeeks.org/how-to-pop-an-alert-message-box-using-php/
} else {
echo 'query error: ' . mysqli_error($conn);
}
}
$sql = 'SELECT *
from User
order by userID desc;
';
$result = mysqli_query($conn, $sql);
$researchers = mysqli_fetch_all($result, MYSQLI_ASSOC);
mysqli_free_result($result);
mysqli_close($conn);
// print_r($researchers);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>COMP353 Project</title>
<link rel="stylesheet" href="index.css">
<!-- CSS only -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
<!-- JavaScript Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-A3rJD856KowSb7dwlZdYEkO39Gagi7vIsF0jrRAoQmDKKtQBHUuLZ9AsSv4jD4Xa" crossorigin="anonymous"></script>
<style>
.dropdown:hover .dropdown-menu{
display: block;
}
</style>
</head>
<body>
<?php include './components/nav.php'; ?>
<div class="col-xs-1 text-center" style="margin-top= 10px;">
<h1 class="h1">Users</h1>
</div>
<table class="table">
<thead>
<tr class="h1" style="font-size: 20px;">
<th scope="col">userID</th>
<th scope="col">Privilege</th>
<th scope="col">First Name</th>
<th scope="col">Last Name</th>
<th scope="col">Citizenship</th>
<th scope="col">Phone</th>
<th scope="col">Email</th>
<th scope="col">Date of Birth</th>
</tr>
</thead>
<tbody>
<?php foreach($researchers as $r) { ?>
<tr class="h1" style="font-size: 15px;">
<th scope="row"> <?php echo htmlspecialchars($r['userID']); ?> </th>
<td> <?php echo htmlspecialchars($r['privilegeName']); ?> </td>
<td> <?php echo htmlspecialchars($r['firstName']); ?> </td>
<td> <?php echo htmlspecialchars($r['lastName']); ?> </td>
<td> <?php echo htmlspecialchars($r['citizenship']); ?> </td>
<td> <?php echo htmlspecialchars($r['phoneNumber']); ?> </td>
<td> <?php echo htmlspecialchars($r['email']); ?> </td>
<td> <?php echo htmlspecialchars($r['dob']); ?> </td>
<?php
if(isset($_SESSION['privilegeName']) && $_SESSION['privilegeName'] == "Administrator"){
echo '<td> <form action="allUsers.php" method="POST">
<input type="hidden" name="userID" value="'.$r["userID"].'">
<input type="submit" class="btn btn-lg btn-danger" value="Delete" name="delete">
</form> </td>';
}
else
{
echo '<td> <button type="button" class="btn btn-lg btn-danger" disabled>Delete</button> </td>';
}
?>
</tr>
<?php } ?>
</tbody>
</table>
</body>
</html>