Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- date_default_timezone_set("Asia/Dhaka");
- header_remove('Access-Control-Allow-Origin');
- header('Access-Control-Allow-Origin: *');
- $servername = "";
- $username = "";;
- $password = "";
- $dbname = "";
- $conn = new mysqli($servername, $username, $password, $dbname);
- $data = file_get_contents('php://input'); // put the contents of the file into a variable
- $receive = json_decode($data); // decode the JSON feed
- // Data Store for Send
- $return = array();
- // Connection Check
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- // Check POST METHOD
- if ($_SERVER["REQUEST_METHOD"] == 'POST')
- {
- $id = base64_encode(rand(10,100));
- // Data Receive
- $a = $receive->lat;
- $b = $receive->lng;
- $c = $receive->coin;
- // mysql Store qry
- $sql_sp = "INSERT INTO gsm(lat, lng, msg, created, time) VALUES ('". $a ."','". $b ."','". $c ."', CURRENT_DATE(), CURRENT_TIME())";
- if ($conn->query($sql_sp) === TRUE)
- {
- // send response
- echo 200;
- }
- // JSON Encoding to send
- }else{
- echo "Problem";
- }
- $conn->close();
- ?>
Add Comment
Please, Sign In to add comment