Initial commit: Setup Landing Page dan file pertemuan
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
include 'koneksi.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
$nama = isset($_POST['nama_spbu']) ? trim($_POST['nama_spbu']) : '';
|
||||
$hp = isset($_POST['no_hp']) ? trim($_POST['no_hp']) : '';
|
||||
$kategori = isset($_POST['kategori']) ? trim($_POST['kategori']) : '';
|
||||
$lat = isset($_POST['latitude']) ? floatval($_POST['latitude']) : 0.0;
|
||||
$lng = isset($_POST['longitude']) ? floatval($_POST['longitude']) : 0.0;
|
||||
|
||||
if (empty($nama) || $lat == 0.0 || $lng == 0.0) {
|
||||
http_response_code(400);
|
||||
echo "Nama SPBU dan koordinat lokasi wajib diisi!";
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("INSERT INTO spbu_locations (nama_spbu, no_hp, kategori, latitude, longitude) VALUES (?, ?, ?, ?, ?)");
|
||||
$stmt->bind_param("sssdd", $nama, $hp, $kategori, $lat, $lng);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
echo "Data SPBU berhasil disimpan!";
|
||||
} else {
|
||||
http_response_code(500);
|
||||
echo "Gagal menyimpan data: " . $conn->error;
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
} else {
|
||||
http_response_code(405);
|
||||
echo "Metode tidak diizinkan";
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user