parent
dbd4ce6851
commit
9929a1cf03
@ -1,8 +1,13 @@
|
||||
<?php
|
||||
$username=$_ENV["CODEFIRST_CLIENTDRONE_ENV_INNODB_USER"];
|
||||
$host=$_ENV["CODEFIRST_CLIENTDRONE_ENV_INNODB_HOST"];
|
||||
$password=$_ENV["CODEFIRST_CLIENTDRONE_ENV_INNODB_PASSWORD"];
|
||||
$db_name=$_ENV["CODEFIRST_CLIENTDRONE_ENV_INNODB_DATABASE"];
|
||||
$username="dafldev";
|
||||
$host="89.83.53.34";
|
||||
$password="wrap";
|
||||
$db_name="positiondaflmusic";
|
||||
|
||||
$connect=mysqli_connect($host,$username,$password,$db_name);
|
||||
|
||||
if (mysqli_connect_errno()) {
|
||||
print(json_encode("Failed to connect to MySQL"));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
@ -1,20 +1,26 @@
|
||||
<?php
|
||||
$connect="";
|
||||
include "config.php";
|
||||
$id = mysqli_real_escape_string($connect, $_POST['id']);
|
||||
$latitude = mysqli_real_escape_string($connect, $_POST['latitude']);
|
||||
$longitude = mysqli_real_escape_string($connect, $_POST['longitude']);
|
||||
$idMusic = mysqli_real_escape_string($connect, $_POST['idMusic']);
|
||||
|
||||
$latitude=doubleval($latitude);
|
||||
$longitude=doubleval($longitude);
|
||||
/*
|
||||
$query = "DELETE FROM gps WHERE (SELECT TIMESTAMPDIFF(MINUTE,CURRENT_TIMESTAMP,dateLog))>10;";
|
||||
$results = mysqli_query($connect, $query);
|
||||
*/
|
||||
$query = "DELETE FROM gps WHERE id='$id';";
|
||||
$results = mysqli_query($connect, $query);
|
||||
|
||||
$query = "INSERT INTO gps (id,latitude,longitude,idMusic,dateLog) VALUES('$id','$latitude','$longitude','$idMusic',CURRENT_TIMESTAMP);";
|
||||
$results = mysqli_query($connect, $query);
|
||||
$connect=""; //Else PHP send an error, "connect don't exist", but that work anyway, this is just to remove a fake error
|
||||
$res=include "config.php"; //$res get the result of the calling of "config.php"
|
||||
if ($res != 1){ //Check if config.php work
|
||||
print (json_encode("Failed to connect to MySQL")); //Return a json string, so the dart script can interpret the error
|
||||
}
|
||||
if (!empty($_POST)) { //Check if the method POST return something
|
||||
$id = mysqli_real_escape_string($connect, $_POST['id']); //Get the result of POST method
|
||||
$latitude = mysqli_real_escape_string($connect, $_POST['latitude']); //Get the result of POST method
|
||||
$longitude = mysqli_real_escape_string($connect, $_POST['longitude']); //Get the result of POST method
|
||||
$idMusic = mysqli_real_escape_string($connect, $_POST['idMusic']); //Get the result of POST method
|
||||
$latitude = doubleval($latitude); //Convert a string to a double
|
||||
$longitude = doubleval($longitude); //Convert a string to a double
|
||||
/*
|
||||
$query = "DELETE FROM gps WHERE (SELECT TIMESTAMPDIFF(MINUTE,CURRENT_TIMESTAMP,dateLog))>10;";
|
||||
$results = mysqli_query($connect, $query);
|
||||
*/
|
||||
$query = "DELETE FROM gps WHERE id='$id';"; //Delete the actual line and replace this line with the next lines
|
||||
$results = mysqli_query($connect, $query); //Execute the SQL command
|
||||
|
||||
$query = "INSERT INTO gps (id,latitude,longitude,idMusic,dateLog)
|
||||
VALUES('$id','$latitude','$longitude','$idMusic',CURRENT_TIMESTAMP);"; //Insert into the database the new data and new information about this user
|
||||
$results = mysqli_query($connect, $query); //Execute the SQL command
|
||||
}else{ //If the method POST return nothing
|
||||
print (json_encode("The POST method failed")); //Return a json string, so the dart script can interpret the error
|
||||
}
|
Loading…
Reference in new issue