doushishi2415 2017-02-08 21:08 采纳率: 0%
浏览 41
已采纳

将帖子内容存储到变量

http request code

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)

So my problem I think is in the php part when I enter mysite.com/parse.php?lt=12.123123&ln=123.123123 to test if it's working and it does but when I the http request code on HttpRequest it but the send value is both 0.000000.

  • 写回答

1条回答 默认 最新

  • doucan4815 2017-02-08 21:28
    关注

    If you aren't sure whether the request has come to you via a GET or a POST method, you could try something like this

    $lt = isset($_GET['lt']) ? $_GET['lt'] : (isset($_POST['lt']) ? $_POST['lt'] : null);
    $ln = isset($_GET['ln']) ? $_GET['ln'] : (isset($_POST['ln']) ? $_POST['ln'] : null);
    

    There might be another option called $_REQUEST which encompasses both $_GET and $_POST but has it own quirks too. Please have a read on the following link to get a better idea:

    Among $_REQUEST, $_GET and $_POST which one is the fastest?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改