<?php

include 'connection.php';

// Get data from POST request
$deviceName = isset($_POST['devicename']) ? $_POST['devicename'] : '';
$longitude = isset($_POST['longitude']) ? $_POST['longitude'] : '';
$latitude = isset($_POST['latitude']) ? $_POST['latitude'] : '';


// Insert data into users table
$sql = "INSERT INTO location (devicename, longitude, latitude) VALUES (:devicename, :longitude, :latitude)";
$stmt = $conn->prepare($sql);
$stmt->bindParam(':devicename', $deviceName);
$stmt->bindParam(':longitude', $longitude);
$stmt->bindParam(':latitude', $latitude);


if ($stmt->execute()) {
    echo "Data inserted successfully";
    
} else {
    echo "Error: " . $sql . "<br>" . $stmt->errorInfo()[2];
}

?>
