PHP Post Webservice Issue -
trying implement post webservice in php can used in ios app communicating db. can please identify mistake.
please find code below. saying "request method not accepted" status 0 returned
<?php // create connection $con=mysqli_connect("myhost.com","myuser","mypassword","mydb"); if($_server['request_method'] == "post"){ // data $lat= isset($_post['lat']) ? mysql_real_escape_string($_post['long']) : ""; $long= isset($_post['long']) ? mysql_real_escape_string($_post['long']) : ""; $timestamp = isset($_post['timestamp']) ? mysql_real_escape_string($_post['timestamp']) : ""; $deviceid = isset($_post['deviceid']) ? mysql_real_escape_string($_post['deviceid']) : ""; // insert data data base $sql = "insert `gpsreporting` (`lat`, `long`, `timestamp`, `deviceid`) values ('$lat', '$long', '$timestamp', '$deviceid');"; $qur = mysql_query($sql); if($qur){ $json = array("status" => 1, "msg" => "done user added!"); }else{ $json = array("status" => 0, "msg" => "error adding user!"); } }else{ $json = array("status" => 0, "msg" => "request method not accepted"); } @mysql_close($conn); /* output header */ header('content-type: application/json'); echo json_encode($json);
Comments
Post a Comment