-
Notifications
You must be signed in to change notification settings - Fork 0
/
GpsPostData.php
22 lines (20 loc) · 1 KB
/
GpsPostData.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
//Checks if it is a HTTP request method is POST
if ($_SERVER["REQUEST_METHOD"] == 'POST')
{
//Include database connection php file
include('GeoDBConnection.php');
//Get JSON data from HTTP request & decode json data into php array
$json = file_get_contents('php://input');
$gpsdata = json_decode($json, true);
//Prepare SQL statement for inserting data into database, followed by binding the parameters to the SQL statement and executing the sql statement
$sqlstatement = $conn->prepare("INSERT INTO records (SecGuardID, SecBTAdrs, RecordTime, Altitude, Latitude, Longitude, Floor) VALUES (?, ?, ?, ?, ?, ?, ?);");
$sqlstatement->bind_param("issdddi", $gpsdata['secguardid'], $gpsdata['btmacaddress'], $gpsdata['recordtime'], $gpsdata['altitude'], $gpsdata['latitude'], $gpsdata['longitude'], $gpsdata['floor']);
$sqlstatement->execute();
}
else //If HTTP request method is not POST
{
//Display error message and exit script
die("ERROR: Request method not POST");
}
?>