35 lines
968 B
PHP
Executable File
35 lines
968 B
PHP
Executable File
<?php
|
|
require_once __DIR__ . '/../../connect.php';
|
|
|
|
$passengerId = filterRequest("passengerId");
|
|
$lat = filterRequest("lat");
|
|
$lng = filterRequest("lng");
|
|
$rideId = filterRequest("rideId");
|
|
|
|
// Validate the latitude and longitude
|
|
if ($lat === '' || $lng === '') {
|
|
jsonError("Latitude and longitude cannot be empty");
|
|
exit;
|
|
}
|
|
|
|
// Prepare an SQL statement with placeholders
|
|
$sql = "INSERT INTO `passengerlocation`( `passengerId`, `lat`, `lng`, `rideId`) VALUES (:passengerId, :lat, :lng, :rideId)";
|
|
|
|
$stmt = $con->prepare($sql);
|
|
|
|
// Bind the parameters to the SQL query
|
|
$stmt->bindParam(':passengerId', $passengerId);
|
|
$stmt->bindParam(':lat', $lat);
|
|
$stmt->bindParam(':lng', $lng);
|
|
$stmt->bindParam(':rideId', $rideId);
|
|
|
|
// Execute the statement
|
|
if ($stmt->execute()) {
|
|
// Print a success message
|
|
jsonSuccess(null, "Passenger location saved successfully");
|
|
} else {
|
|
// Print a failure message
|
|
jsonError("Failed to save passenger location");
|
|
}
|
|
?>
|