| Server IP : 172.67.187.206 / Your IP : 172.71.28.155 Web Server : Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30 System : Windows NT WIN-ECQAAA40806 6.2 build 9200 (Windows Server 2012 Standard Edition) i586 User : SYSTEM ( 0) PHP Version : 5.6.30 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /Inetpub/www/training/admin/ |
Upload File : |
<?php
include("../session.php");
if ($role != 'admin') {
header("Location: ../index.php");
exit;
}
include("../db.php");
// ลบผู้ใช้ (ถ้ามี)
if (isset($_GET['del'])) {
$user_id = intval($_GET['del']);
mysqli_query($conn, "DELETE FROM users WHERE id = $user_id");
header("Location: users.php");
exit;
}
// ดึงข้อมูลผู้ใช้
$result = mysqli_query($conn, "SELECT * FROM users ORDER BY id ASC");
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>จัดการผู้ใช้</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<h3 class="text-center">จัดการผู้ใช้</h3>
<p class="text-right">
<a href="dashboard.php" class="btn btn-default btn-sm">← กลับหน้าหลัก</a>
<a href="user_form.php" class="btn btn-primary btn-sm">+ เพิ่มผู้ใช้</a>
</p>
<table class="table table-bordered">
<thead>
<tr>
<th>#</th>
<th>ชื่อผู้ใช้</th>
<th>อีเมล</th>
<th>ประเภท</th>
<th>จัดการ</th>
</tr>
</thead>
<tbody>
<?php
while ($user = mysqli_fetch_assoc($result)):
?>
<tr>
<td><?php echo $user['id']; ?></td>
<td><?php echo htmlspecialchars($user['username']); ?></td>
<td><?php echo htmlspecialchars($user['email']); ?></td>
<td><?php echo ucfirst($user['role']); ?></td>
<td>
<a href="user_form.php?id=<?php echo $user['id']; ?>" class="btn btn-info btn-xs">แก้ไข</a>
<a href="?del=<?php echo $user['id']; ?>" class="btn btn-danger btn-xs" onclick="return confirm('ลบผู้ใช้คนนี้?')">ลบ</a>
</td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
</div>
</body>
</html>