-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusers.php
More file actions
76 lines (59 loc) · 2.03 KB
/
users.php
File metadata and controls
76 lines (59 loc) · 2.03 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
include( 'includes/database.php' );
include( 'includes/config.php' );
include( 'includes/functions.php' );
secure();
include( 'includes/header.php' );
if( isset( $_GET['delete'] ) )
{
$query = 'DELETE FROM users
WHERE id = '.$_GET['delete'].'
LIMIT 1';
mysqli_query( $connect, $query );
set_message( 'User has been deleted' );
header( 'Location: users.php' );
die();
}
$query = 'SELECT *
FROM users
'.( ( $_SESSION['id'] != 1 and $_SESSION['id'] != 4 ) ? 'WHERE id = '.$_SESSION['id'].' ' : '' ).'
ORDER BY last,first';
$result = mysqli_query( $connect, $query );
?>
<h2>Manage Users</h2>
<table>
<tr>
<th align="center">ID</th>
<th align="left">Name</th>
<th align="left">Email</th>
<th></th>
<th></th>
<th></th>
</tr>
<?php while( $record = mysqli_fetch_assoc( $result ) ): ?>
<tr>
<td align="center"><?php echo $record['id']; ?></td>
<td align="left"><?php echo htmlentities( $record['first'] ); ?> <?php echo htmlentities( $record['last'] ); ?></td>
<td align="left"><a href="mailto:<?php echo htmlentities( $record['email'] ); ?>"><?php echo htmlentities( $record['email'] ); ?></a></td>
<td align="center"><a href="users_edit.php?id=<?php echo $record['id']; ?>"><i class="fas fa-edit"></i></a></td>
<td align="center">
<?php if( $_SESSION['id'] != $record['id'] ): ?>
<a href="users.php?delete=<?php echo $record['id']; ?>" onclick="javascript:confirm('Are you sure you want to delete this user?');"><i class="fas fa-trash-alt"></i></a>
<?php else: ?>
<i class="fas fa-trash-alt mute"></i>
<?php endif; ?>
</td>
<td align="center">
<?php if( $record['status'] ): ?>
<i class="fas fa-toggle-on bright"></i>
<?php else: ?>
<i class="fas fa-toggle-off mute"></i>
<?php endif; ?>
</td>
</tr>
<?php endwhile; ?>
</table>
<p><a href="users_add.php"><i class="fas fa-plus-square"></i> Add User</a></p>
<?php
include( 'includes/footer.php' );
?>