Initial commit: Setup Landing Page dan file pertemuan
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
include 'koneksi.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
$id = isset($_POST['id']) ? intval($_POST['id']) : 0;
|
||||
$tabel = isset($_POST['tabel']) ? trim($_POST['tabel']) : '';
|
||||
$stmt = null;
|
||||
|
||||
if ($id <= 0) {
|
||||
http_response_code(400);
|
||||
echo "ID tidak valid!";
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($tabel == 'jalan') {
|
||||
$nama = isset($_POST['nama_jalan']) ? trim($_POST['nama_jalan']) : '';
|
||||
$status = isset($_POST['status']) ? trim($_POST['status']) : '';
|
||||
|
||||
if (empty($nama)) {
|
||||
http_response_code(400);
|
||||
echo "Nama jalan tidak boleh kosong!";
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("UPDATE jalan SET nama_jalan=?, status=? WHERE id=?");
|
||||
$stmt->bind_param("ssi", $nama, $status, $id);
|
||||
|
||||
} else if ($tabel == 'parsil') {
|
||||
$nama = isset($_POST['nama_pemilik']) ? trim($_POST['nama_pemilik']) : '';
|
||||
$status = isset($_POST['status']) ? trim($_POST['status']) : '';
|
||||
|
||||
if (empty($nama)) {
|
||||
http_response_code(400);
|
||||
echo "Nama pemilik tidak boleh kosong!";
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("UPDATE parsil SET nama_pemilik=?, status=? WHERE id=?");
|
||||
$stmt->bind_param("ssi", $nama, $status, $id);
|
||||
|
||||
} else {
|
||||
http_response_code(400);
|
||||
echo "Tabel tidak valid!";
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($stmt) {
|
||||
if ($stmt->execute()) {
|
||||
echo "Data berhasil diperbarui!";
|
||||
} else {
|
||||
http_response_code(500);
|
||||
echo "Gagal memperbarui: " . $conn->error;
|
||||
}
|
||||
$stmt->close();
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
} else {
|
||||
http_response_code(405);
|
||||
echo "Metode tidak diizinkan";
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user