23 lines
558 B
PHP
23 lines
558 B
PHP
<?php
|
|
include 'koneksi.php';
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$id = intval($_POST['id']);
|
|
$foto = mysqli_real_escape_string($conn, $_POST['foto']);
|
|
|
|
// Hapus file foto
|
|
$targetDir = "uploads/";
|
|
if (!empty($foto) && file_exists($targetDir . $foto)) {
|
|
unlink($targetDir . $foto);
|
|
}
|
|
|
|
$query = "DELETE FROM jalan_rusak WHERE id=$id";
|
|
if (mysqli_query($conn, $query)) {
|
|
echo "success";
|
|
} else {
|
|
echo "db_error: " . mysqli_error($conn);
|
|
}
|
|
} else {
|
|
echo "invalid_request";
|
|
}
|
|
?>
|