Initial commit
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
require 'db.php';
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
http_response_code(405);
|
||||
echo json_encode(['status' => 'error', 'message' => 'Method not allowed.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$id = $_POST['id'] ?? null;
|
||||
if ($id === null) {
|
||||
http_response_code(400);
|
||||
echo json_encode(['status' => 'error', 'message' => 'Missing id.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM tb_jalan WHERE id = ?";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
|
||||
if ($stmt->execute([(int)$id])) {
|
||||
echo json_encode(['status' => 'success', 'message' => 'Jalan deleted.']);
|
||||
} else {
|
||||
http_response_code(500);
|
||||
echo json_encode(['status' => 'error', 'message' => 'Failed to delete jalan.']);
|
||||
}
|
||||
Reference in New Issue
Block a user