first commit
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
include 'koneksi.php';
|
||||
|
||||
$idRaw = $_POST['id'] ?? null;
|
||||
$id = filter_var($idRaw, FILTER_VALIDATE_INT);
|
||||
$namaMasjid = trim($_POST['nama_masjid'] ?? '');
|
||||
$picMasjid = trim($_POST['pic_masjid'] ?? '');
|
||||
$alamat = trim($_POST['alamat'] ?? '');
|
||||
$radiusRaw = $_POST['radius'] ?? null;
|
||||
$radius = is_numeric($radiusRaw) ? (float) $radiusRaw : null;
|
||||
|
||||
if ($id === false || $id === null || $id <= 0 || $namaMasjid === '' || $picMasjid === '' || $alamat === '' || $radius === null || $radius < 100 || $radius > 5000) {
|
||||
http_response_code(400);
|
||||
exit('error');
|
||||
}
|
||||
|
||||
$statement = mysqli_prepare(
|
||||
$conn,
|
||||
"UPDATE masjid SET nama_masjid = ?, pic_masjid = ?, alamat = ?, radius = ? WHERE id = ?"
|
||||
);
|
||||
|
||||
mysqli_stmt_bind_param($statement, "sssdi", $namaMasjid, $picMasjid, $alamat, $radius, $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