26 lines
763 B
PHP
26 lines
763 B
PHP
<?php
|
|
ob_start();
|
|
include 'koneksi.php';
|
|
$output = ob_get_clean();
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
$id = $_POST['id_restriction'] ?? '';
|
|
|
|
if (empty($id)) {
|
|
echo json_encode(['status' => 'error', 'message' => 'ID is required.']);
|
|
exit;
|
|
}
|
|
|
|
try {
|
|
$stmt = $pdo->prepare("DELETE FROM room_restrictions WHERE id_restriction = ?");
|
|
$result = $stmt->execute([$id]);
|
|
if ($result) {
|
|
echo json_encode(['status' => 'success', 'message' => 'Restriction deleted successfully.']);
|
|
} else {
|
|
echo json_encode(['status' => 'error', 'message' => 'Failed to delete: ' . implode(' ', $stmt->errorInfo())]);
|
|
}
|
|
} catch (Exception $e) {
|
|
echo json_encode(['status' => 'error', 'message' => 'Exception: ' . $e->getMessage()]);
|
|
}
|