menambahkan fitur edit data pengguna dan memperbarui landing page

This commit is contained in:
powji17
2026-06-10 17:39:36 +07:00
parent 7c1b4375e7
commit 6158f4b1a4
16 changed files with 869 additions and 455 deletions
@@ -0,0 +1,28 @@
<?php
require_once '../../auth.php';
requireRole('admin');
header('Content-Type: application/json');
$conn = new mysqli("localhost", "root", "", "webgis");
$data = json_decode(file_get_contents("php://input"), true);
$id = (int) $data['id'];
// Tidak boleh hapus diri sendiri
if ($id === (int) $_SESSION['user']) {
echo json_encode(["status" => "error", "message" => "Tidak bisa menghapus akun sendiri"]);
exit;
}
$stmt = $conn->prepare("DELETE FROM users WHERE id = ?");
$stmt->bind_param("i", $id);
if ($stmt->execute()) {
echo json_encode(["status" => "success"]);
} else {
echo json_encode(["status" => "error", "message" => $stmt->error]);
}
$stmt->close();
$conn->close();
?>