feat: memisahkan monorepo jadi 2 project (Kemiskinan & Publik)
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
session_start();
|
||||
// Role check: hanya admin yang boleh menghapus
|
||||
if (!isset($_SESSION['role']) || $_SESSION['role'] !== 'admin') {
|
||||
header('Content-Type: application/json');
|
||||
http_response_code(403);
|
||||
echo json_encode(['status'=>'error','message'=>'Akses ditolak. Hanya admin yang dapat menghapus data.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
include '../koneksi.php';
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$id = (int)($_POST['id'] ?? $_GET['id'] ?? 0);
|
||||
if (!$id) { echo json_encode(['status'=>'error','message'=>'ID tidak valid.']); exit; }
|
||||
|
||||
try {
|
||||
$pdo->prepare("DELETE FROM points WHERE id=?")->execute([$id]);
|
||||
echo json_encode(['status'=>'success']);
|
||||
} catch (PDOException $e) {
|
||||
echo json_encode(['status'=>'error','message'=>$e->getMessage()]);
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user