first commit
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
include 'koneksi.php';
|
||||
|
||||
$idRaw = $_POST['id'] ?? null;
|
||||
$id = filter_var($idRaw, FILTER_VALIDATE_INT);
|
||||
|
||||
if ($id === false || $id === null || $id <= 0) {
|
||||
http_response_code(400);
|
||||
exit('error');
|
||||
}
|
||||
|
||||
$statement = mysqli_prepare($conn, "DELETE FROM kavling WHERE id = ?");
|
||||
mysqli_stmt_bind_param($statement, "i", $id);
|
||||
|
||||
try {
|
||||
if (mysqli_stmt_execute($statement)) {
|
||||
echo 'success';
|
||||
} else {
|
||||
http_response_code(500);
|
||||
echo 'error';
|
||||
}
|
||||
} catch (mysqli_sql_exception $exception) {
|
||||
http_response_code(500);
|
||||
echo 'error: ' . $exception->getMessage();
|
||||
}
|
||||
|
||||
mysqli_stmt_close($statement);
|
||||
?>
|
||||
Reference in New Issue
Block a user