-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsendLocalisation.php
32 lines (30 loc) · 1.03 KB
/
sendLocalisation.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
include("conn.php");
header('Content-type: application/json ');
ini_set('display_errors','On');
$id_user = $_POST['id_user'];
$longitude = $_POST['longitude'];
$latitude = $_POST['latitude'];
$date = date("Y-m-d H:i:s");
$user=array();
$response = array("success" => 0, "error" => 0);
$sql = "INSERT INTO localisation(id_user, localisation_long, localisation_lat, localisation_date)
VALUES(:id_user, :longitude, :latitude, :dat) ";
$req = $pdo->prepare($sql);
$resultat = $req->execute(array(
'id_user' => $id_user,
'longitude' => $longitude,
'latitude' => $latitude,
'dat' => $date
));
print_r("Resultat : ".$resultat);
if ($resultat == 1) {
$response["success"] = 1;
$response["msg"] = "Insertion éffectuée avec succès";
echo json_encode($response);
}else{
$response["success"] = 0;
$response["msg"] = "Erreur lors de l'insertion";
echo json_encode($response);
}
?>