feat(landing-page):penambahan landing page utama pdemisah antar fitur
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
include __DIR__ . '/../../db_config.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$id = (int)($_POST['id'] ?? 0);
|
||||
if ($id <= 0) {
|
||||
http_response_code(400);
|
||||
echo json_encode(['status' => 'error', 'message' => 'ID laporan tidak valid']);
|
||||
$conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
// Optional: Get file path and delete physical image file
|
||||
$stmtSelect = $conn->prepare('SELECT gambar FROM jalan_rusak WHERE id = ?');
|
||||
if ($stmtSelect) {
|
||||
$stmtSelect->bind_param('i', $id);
|
||||
$stmtSelect->execute();
|
||||
$stmtSelect->bind_result($gambar);
|
||||
if ($stmtSelect->fetch()) {
|
||||
if ($gambar && file_exists(__DIR__ . '/../../' . $gambar)) {
|
||||
@unlink(__DIR__ . '/../../' . $gambar);
|
||||
}
|
||||
}
|
||||
$stmtSelect->close();
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare('DELETE FROM jalan_rusak WHERE id = ?');
|
||||
if (!$stmt) {
|
||||
http_response_code(500);
|
||||
echo json_encode(['status' => 'error', 'message' => $conn->error]);
|
||||
$conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt->bind_param('i', $id);
|
||||
if ($stmt->execute()) {
|
||||
echo json_encode(['status' => 'success', 'message' => 'Laporan jalan rusak berhasil dihapus']);
|
||||
} else {
|
||||
http_response_code(500);
|
||||
echo json_encode(['status' => 'error', 'message' => $stmt->error]);
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
http_response_code(405);
|
||||
echo json_encode(['status' => 'error', 'message' => 'Method tidak diizinkan']);
|
||||
$conn->close();
|
||||
?>
|
||||
Reference in New Issue
Block a user