http请求代码
POST /parse.php HTTP/1.1
Host: mysite.com
Connection: Keep-Alive
Content-Length: 26
Content-Type: application/x-www-urlencoded
lt=12.123123&ln=123.123123
php code
//connect to database codes here
$database = "update name_tbl set lat='".$_GET['lt']."', lng='".$_GET['ln']."' where id=1";
mysqli_query($conn, $database)
所以我认为我的问题出在php部分,当我输入mysite.com/parse.php?lt=12.123123&ln=123.123123来测试它是否正常工作时它会发生但是当我发出http请求时 HttpRequest 上的代码,但发送值均为0.000000。
答案 0 :(得分:0)
如果您不确定该请求是通过GET
还是POST
方式发送给您的,您可以尝试这样的
$lt = isset($_GET['lt']) ? $_GET['lt'] : (isset($_POST['lt']) ? $_POST['lt'] : null);
$ln = isset($_GET['ln']) ? $_GET['ln'] : (isset($_POST['ln']) ? $_POST['ln'] : null);
可能还有另一个名为$_REQUEST
的选项,其中包含$_GET
和$_POST
,但它也有自己的怪癖。请阅读以下链接以获得更好的主意: