-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadminlistalluser.php
More file actions
executable file
·135 lines (123 loc) · 4.59 KB
/
Copy pathadminlistalluser.php
File metadata and controls
executable file
·135 lines (123 loc) · 4.59 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
include('dbconnection.php'); // Ensure your database connection file is included
// Fetch data from the users table
$query = "SELECT * FROM users"; // Replace 'users' with your actual table name
$result = mysqli_query($conn, $query);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Movie Management</title>
<link rel="stylesheet" href="admin.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.0/css/all.min.css" integrity="sha512-9xKTRVabjVeZmc+GUW8GgSmcREDunMM+Dt/GrzchfN8tkwHizc5RP4Ok/MXFFy5rIjJjzhndFScTceq5e6GvVQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<style>
/* Table styles */
table {
width: 90%;
margin: 80px 100px;
border-collapse: collapse;
text-align: center;
}
th,
td {
border: 1px solid #ddd;
padding: 8px;
}
th {
background-color: #007bff;
color: white;
font-weight: bold;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
tr:hover {
background-color: #ddd;
}
.delete-btn {
background-color: #e74c3c;
color: white;
border: none;
padding: 5px 10px;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s;
}
.delete-btn:hover {
background-color: #c0392b;
}
</style>
</head>
<body>
<div id="wrapper">
<!-- Sidebar -->
<aside id="sidebar">
<div>
<img src="Images/logo12.png" height="110px" width="140px" style="margin: auto; margin-left:70px" alt="Logo" />
<h2 style=" text-align: center;">Admin Panel</h2>
</div>
<nav>
<ul>
<li><a href="adminhome.php"><i class="fa-solid fa-house " style="margin-right:12px"></i>Home</a></li>
<li><a href="adminupload.php" id="addMovieLink" style="margin-right:18px"> <i class="fa-solid fa-clapperboard"></i> Add Movies</a></li>
<li><a href="adminlistalluser.php" style="margin-right:18px"><i class="fa-solid fa-users"></i> List All Users</a></li>
<li><a href="adminlogout.php"> <i class="fa-solid fa-right-from-bracket"></i> Logout</a></li>
</ul>
</nav>
</aside>
<!-- Display user table -->
<div class="display">
<h2 style="text-align: center;">List of Users</h2>
<table>
<thead>
<tr>
<th>UID</th>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Mobile</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
echo "<tr>
<td>{$row['uid']}</td>
<td>{$row['fname']}</td>
<td>{$row['lname']}</td>
<td>{$row['email']}</td>
<td>{$row['mobile']}</td>
<td><button class='delete-btn' onclick='deleteUser({$row['uid']})'>X</button></td>
</tr>";
}
} else {
echo "<tr><td colspan='6'>No users found</td></tr>";
}
?>
</tbody>
</table>
</div>
</div>
<script>
// JavaScript to handle delete action
function deleteUser(uid) {
if (confirm('Are you sure you want to delete this user?')) {
// Send delete request to backend
fetch(`deleteUser.php?uid=${uid}`, {
method: 'GET'
})
.then(response => response.json())
.then(data => {
alert(data.message);
location.reload(); // Reload the page after deletion
})
.catch(error => console.error('Error deleting user:', error));
}
}
</script>
</body>
</html>