Files
intaleq_v3_pure_php/ride/location/addpassengerLocation.php
2026-04-28 13:04:27 +03:00

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");
}
?>