<?php
// Establish database connection
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "sheeld";

$Trip_ID = $_GET['Trip_ID'];


$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// Prepare and bind
$stmt = $conn->prepare("INSERT INTO trip_spots (Trip_ID, Spot_Number, Latitude, Longitude) VALUES ('$Trip_ID', ?, ?, ?)");
$stmt->bind_param("iss", $index, $latitude, $longitude);

// Fetch values from POST request and save
$index = $_POST['index'];
$latitude = $_POST['latitude'];
$longitude = $_POST['longitude'];

$stmt->execute();

$stmt->close();
$conn->close();
?>
