memperbaiki koneksi database pada project 1 dan project 2

This commit is contained in:
powji17
2026-06-12 06:23:23 +07:00
parent 070ba54cf3
commit 3cc437bdf8
16 changed files with 32 additions and 120 deletions
+2 -12
View File
@@ -1,18 +1,8 @@
<?php <?php
header('Content-Type: application/json'); header('Content-Type: application/json');
// Konfigurasi Database (Sesuaikan) require_once '../config.php';
$host = "localhost"; $conn = getDB();
$user = "root";
$pass = "";
$db = "webgis"; // UBAH INI
$conn = new mysqli($host, $user, $pass, $db);
if ($conn->connect_error) {
echo json_encode(["status" => "error", "message" => "Koneksi database gagal"]);
exit;
}
$data = json_decode(file_get_contents("php://input"), true); $data = json_decode(file_get_contents("php://input"), true);
+2 -12
View File
@@ -1,18 +1,8 @@
<?php <?php
header('Content-Type: application/json'); header('Content-Type: application/json');
// Konfigurasi Database (Sesuaikan dengan milik Anda) require_once '../config.php';
$host = "localhost"; $conn = getDB();
$user = "root";
$pass = "";
$db = "webgis"; // UBAH INI
$conn = new mysqli($host, $user, $pass, $db);
if ($conn->connect_error) {
echo json_encode(["status" => "error", "message" => "Koneksi database gagal"]);
exit;
}
// Ambil semua data dari tabel spbu_point // Ambil semua data dari tabel spbu_point
$sql = "SELECT * FROM spbu_point"; $sql = "SELECT * FROM spbu_point";
+2 -12
View File
@@ -4,18 +4,8 @@
header('Content-Type: application/json'); header('Content-Type: application/json');
// Konfigurasi Database (Sesuaikan dengan milik Anda) // Konfigurasi Database (Sesuaikan dengan milik Anda)
$host = "localhost"; require_once '../config.php';
$user = "root"; $conn = getDB();
$pass = "";
$db = "webgis"; // UBAH INI!
// Koneksi ke database
$conn = new mysqli($host, $user, $pass, $db);
if ($conn->connect_error) {
echo json_encode(["status" => "error", "message" => "Koneksi database gagal"]);
exit;
}
// Ambil data JSON yang dikirim oleh Fetch API // Ambil data JSON yang dikirim oleh Fetch API
$data = json_decode(file_get_contents("php://input"), true); $data = json_decode(file_get_contents("php://input"), true);
+2 -11
View File
@@ -2,17 +2,8 @@
header('Content-Type: application/json'); header('Content-Type: application/json');
// Konfigurasi Database (Sesuaikan dengan milik Anda) // Konfigurasi Database (Sesuaikan dengan milik Anda)
$host = "localhost"; require_once '../config.php';
$user = "root"; $conn = getDB();
$pass = "";
$db = "webgis"; // UBAH INI
$conn = new mysqli($host, $user, $pass, $db);
if ($conn->connect_error) {
echo json_encode(["status" => "error", "message" => "Koneksi database gagal"]);
exit;
}
$data = json_decode(file_get_contents("php://input"), true); $data = json_decode(file_get_contents("php://input"), true);
+2 -1
View File
@@ -1,6 +1,7 @@
<?php <?php
header('Content-Type: application/json'); header('Content-Type: application/json');
$conn = new mysqli("localhost", "root", "", "webgis"); // UBAH DB require_once '../config.php';
$conn = getDB();
$data = json_decode(file_get_contents("php://input"), true); $data = json_decode(file_get_contents("php://input"), true);
if ($data && isset($data['id'])) { if ($data && isset($data['id'])) {
+2 -11
View File
@@ -2,17 +2,8 @@
header('Content-Type: application/json'); header('Content-Type: application/json');
// Konfigurasi Database (Sesuaikan dengan milik Anda) // Konfigurasi Database (Sesuaikan dengan milik Anda)
$host = "localhost"; require_once '../config.php';
$user = "root"; $conn = getDB();
$pass = "";
$db = "webgis"; // UBAH INI
$conn = new mysqli($host, $user, $pass, $db);
if ($conn->connect_error) {
echo json_encode(["status" => "error", "message" => "Koneksi database gagal"]);
exit;
}
$data = json_decode(file_get_contents("php://input"), true); $data = json_decode(file_get_contents("php://input"), true);
+2 -11
View File
@@ -2,17 +2,8 @@
header('Content-Type: application/json'); header('Content-Type: application/json');
// Konfigurasi Database (Sesuaikan) // Konfigurasi Database (Sesuaikan)
$host = "localhost"; require_once '../config.php';
$user = "root"; $conn = getDB();
$pass = "";
$db = "webgis"; // UBAH INI
$conn = new mysqli($host, $user, $pass, $db);
if ($conn->connect_error) {
echo json_encode(["status" => "error", "message" => "Koneksi database gagal"]);
exit;
}
$data = json_decode(file_get_contents("php://input"), true); $data = json_decode(file_get_contents("php://input"), true);
+2 -1
View File
@@ -1,6 +1,7 @@
<?php <?php
header('Content-Type: application/json'); header('Content-Type: application/json');
$conn = new mysqli("localhost", "root", "", "webgis"); require_once '../config.php';
$conn = getDB();
$sql = "SELECT * FROM area_polygon"; $sql = "SELECT * FROM area_polygon";
$result = $conn->query($sql); $result = $conn->query($sql);
+2 -1
View File
@@ -1,6 +1,7 @@
<?php <?php
header('Content-Type: application/json'); header('Content-Type: application/json');
$conn = new mysqli("localhost", "root", "", "webgis"); // UBAH DB require_once '../config.php';
$conn = getDB();
$sql = "SELECT * FROM jalan_polyline"; $sql = "SELECT * FROM jalan_polyline";
$result = $conn->query($sql); $result = $conn->query($sql);
+2 -11
View File
@@ -2,17 +2,8 @@
header('Content-Type: application/json'); header('Content-Type: application/json');
// Konfigurasi Database (Sesuaikan dengan milik Anda) // Konfigurasi Database (Sesuaikan dengan milik Anda)
$host = "localhost"; require_once '../config.php';
$user = "root"; $conn = getDB();
$pass = "";
$db = "webgis"; // UBAH INI
$conn = new mysqli($host, $user, $pass, $db);
if ($conn->connect_error) {
echo json_encode(["status" => "error", "message" => "Koneksi database gagal"]);
exit;
}
// Ambil semua data dari tabel spbu_point // Ambil semua data dari tabel spbu_point
$sql = "SELECT * FROM spbu_point"; $sql = "SELECT * FROM spbu_point";
+2 -1
View File
@@ -1,6 +1,7 @@
<?php <?php
header('Content-Type: application/json'); header('Content-Type: application/json');
$conn = new mysqli("localhost", "root", "", "webgis"); require_once '../config.php';
$conn = getDB();
$data = json_decode(file_get_contents("php://input"), true); $data = json_decode(file_get_contents("php://input"), true);
+2 -1
View File
@@ -1,6 +1,7 @@
<?php <?php
header('Content-Type: application/json'); header('Content-Type: application/json');
$conn = new mysqli("localhost", "root", "", "webgis"); // UBAH DB require_once '../config.php';
$conn = getDB();
$data = json_decode(file_get_contents("php://input"), true); $data = json_decode(file_get_contents("php://input"), true);
+2 -12
View File
@@ -4,18 +4,8 @@
header('Content-Type: application/json'); header('Content-Type: application/json');
// Konfigurasi Database (Sesuaikan dengan milik Anda) // Konfigurasi Database (Sesuaikan dengan milik Anda)
$host = "localhost"; require_once '../config.php';
$user = "root"; $conn = getDB();
$pass = "";
$db = "webgis"; // UBAH INI!
// Koneksi ke database
$conn = new mysqli($host, $user, $pass, $db);
if ($conn->connect_error) {
echo json_encode(["status" => "error", "message" => "Koneksi database gagal"]);
exit;
}
// Ambil data JSON yang dikirim oleh Fetch API // Ambil data JSON yang dikirim oleh Fetch API
$data = json_decode(file_get_contents("php://input"), true); $data = json_decode(file_get_contents("php://input"), true);
+2 -6
View File
@@ -1,12 +1,8 @@
<?php <?php
header('Content-Type: application/json'); header('Content-Type: application/json');
// Sesuaikan dengan konfigurasi database Anda // Sesuaikan dengan konfigurasi database Anda
$conn = new mysqli("localhost", "root", "", "webgis"); require_once '../config.php';
$conn = getDB();
if ($conn->connect_error) {
echo json_encode(["status" => "error", "message" => "Koneksi database gagal"]);
exit;
}
$data = json_decode(file_get_contents("php://input"), true); $data = json_decode(file_get_contents("php://input"), true);
+2 -6
View File
@@ -1,12 +1,8 @@
<?php <?php
header('Content-Type: application/json'); header('Content-Type: application/json');
// Sesuaikan dengan konfigurasi database Anda // Sesuaikan dengan konfigurasi database Anda
$conn = new mysqli("localhost", "root", "", "webgis"); require_once '../config.php';
$conn = getDB();
if ($conn->connect_error) {
echo json_encode(["status" => "error", "message" => "Koneksi database gagal"]);
exit;
}
$data = json_decode(file_get_contents("php://input"), true); $data = json_decode(file_get_contents("php://input"), true);
+2 -11
View File
@@ -2,17 +2,8 @@
header('Content-Type: application/json'); header('Content-Type: application/json');
// Konfigurasi Database (Sesuaikan dengan milik Anda) // Konfigurasi Database (Sesuaikan dengan milik Anda)
$host = "localhost"; require_once '../config.php';
$user = "root"; $conn = getDB();
$pass = "";
$db = "webgis"; // UBAH INI
$conn = new mysqli($host, $user, $pass, $db);
if ($conn->connect_error) {
echo json_encode(["status" => "error", "message" => "Koneksi database gagal"]);
exit;
}
$data = json_decode(file_get_contents("php://input"), true); $data = json_decode(file_get_contents("php://input"), true);