35 lines
1.2 KiB
PHP
35 lines
1.2 KiB
PHP
<?php
|
|
// Koneksi ke Database
|
|
$host = "localhost";
|
|
$user = "root";
|
|
$pass = "";
|
|
$db = "nama_database_kamu"; // Sesuaikan dengan nama databasemu
|
|
|
|
$conn = new mysqli($host, $user, $pass, $db);
|
|
if ($conn->connect_error) {
|
|
die("Koneksi Gagal: " . $conn->connect_error);
|
|
}
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|
$type = $_POST['type'];
|
|
$nama_atribut = $_POST['nama_atribut'];
|
|
$status = $_POST['status'];
|
|
$hasil_hitung = $_POST['hasil_hitung'];
|
|
$geojson = $_POST['geojson']; // String GeoJSON dari Leaflet
|
|
|
|
if ($type == 'jalan') {
|
|
$sql = "INSERT INTO data_jalan (nama_jalan, status_jalan, panjang_meter, geojson)
|
|
VALUES ('$nama_atribut', '$status', '$hasil_hitung', '$geojson')";
|
|
} else if ($type == 'parsil') {
|
|
$sql = "INSERT INTO data_parsil (kode_kavling, status_kepemilikan, luas_meter, geojson)
|
|
VALUES ('$nama_atribut', '$status', '$hasil_hitung', '$geojson')";
|
|
}
|
|
|
|
if ($conn->query($sql) === TRUE) {
|
|
echo "<script>alert('Data berhasil disimpan!'); window.location='index.php';</script>";
|
|
} else {
|
|
echo "Error: " . $sql . "<br>" . $conn->error;
|
|
}
|
|
}
|
|
$conn->close();
|
|
?>
|