Files
2026-06-11 21:14:16 +07:00

31 lines
807 B
PHP

<?php
include 'koneksi.php';
$idRaw = $_POST['id'] ?? null;
$radiusRaw = $_POST['radius'] ?? null;
$id = filter_var($idRaw, FILTER_VALIDATE_INT);
$radius = is_numeric($radiusRaw) ? (float) $radiusRaw : null;
if ($id === false || $id === null || $id <= 0 || $radius === null || $radius < 100 || $radius > 5000) {
http_response_code(400);
exit('error');
}
$statement = mysqli_prepare($conn, "UPDATE masjid SET radius = ? WHERE id = ?");
mysqli_stmt_bind_param($statement, "di", $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);
?>