Initial Commit: Tugas Semua Pertemuan
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
<?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";
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user