Guest User

Untitled

a guest
Nov 10th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. <?php
  2. date_default_timezone_set("Asia/Dhaka");
  3. header_remove('Access-Control-Allow-Origin');
  4. header('Access-Control-Allow-Origin: *');
  5.  
  6. $servername = "";
  7. $username = "";;
  8. $password = "";
  9. $dbname = "";
  10.  
  11. $conn = new mysqli($servername, $username, $password, $dbname);
  12.  
  13. $data = file_get_contents('php://input'); // put the contents of the file into a variable
  14. $receive = json_decode($data); // decode the JSON feed
  15.  
  16. // Data Store for Send
  17. $return = array();
  18.  
  19. // Connection Check
  20. if ($conn->connect_error) {
  21. die("Connection failed: " . $conn->connect_error);
  22. }
  23.  
  24. // Check POST METHOD
  25. if ($_SERVER["REQUEST_METHOD"] == 'POST')
  26. {
  27.  
  28. $id = base64_encode(rand(10,100));
  29.  
  30.  
  31. // Data Receive
  32. $a = $receive->lat;
  33. $b = $receive->lng;
  34. $c = $receive->coin;
  35.  
  36.  
  37. // mysql Store qry
  38. $sql_sp = "INSERT INTO gsm(lat, lng, msg, created, time) VALUES ('". $a ."','". $b ."','". $c ."', CURRENT_DATE(), CURRENT_TIME())";
  39.  
  40. if ($conn->query($sql_sp) === TRUE)
  41. {
  42. // send response
  43. echo 200;
  44. }
  45.  
  46. // JSON Encoding to send
  47. }else{
  48. echo "Problem";
  49. }
  50.  
  51.  
  52. $conn->close();
  53. ?>
Add Comment
Please, Sign In to add comment