简体   繁体   English

在表单上使用php和POST,但是request_method表示这是GET

[英]Using php and POST on a form, but request_method says it is a GET

So I have this form that I am submitting to a php script that echos $_SERVER['REQUEST_METHOD']. 因此,我拥有提交给回显$ _SERVER ['REQUEST_METHOD']的php脚本的这种形式。 I do not know why, but even though I specify the POST method in the form, it always echoes GET. 我不知道为什么,但是即使我在表单中指定POST方法,它也始终会回显GET。 Why is this? 为什么是这样? What am I doing wrong? 我究竟做错了什么?

<form action="location.php" method="POST">
<table>
    <tr>
        <td>name</td>
        <td><input type="text" name="name"></td>
    </tr>
    <tr>
        <td>address</td>
        <td><input type="text" name="address"></td>
    </tr>
    <tr>
        <td>lat</td>
        <td><input type="text" name="lat"></td>
    </tr>
    <tr>
        <td>lng</td>
        <td><input type="text" name="lng"></td>
    </tr>
    <tr>
        <td>user</td>
        <td><input type="text" name="user"></td>
    </tr>
    <tr>
        <td>type</td>
        <td><input type="text" name="type"></td>
    </tr>
    <tr>
        <td>method</td>
        <td><input type="text" name="methoda"></td>
    </tr>
    <tr>

        <td><input type="submit" name="submit"></td>
    </tr>
 </table>
</form>

as I have spent countless hours trying to fix a bug related to the "REQUST_METHOD" being wrong in PHP and not finding anything helpful online, this is my report on the issue: Chrome seems to have a bug in the Version 30.0.1599.101 由于我花了无数小时试图修复与PHP中的“ REQUST_METHOD”错误有关的错误,并且找不到在线有用的东西,因此,这是我的报告:Chrome似乎在30.0.1599.101版本中存在错误

my jquery test code was: 我的jQuery测试代码是:

$.ajax({
  type: "POST",
  url: '../Server/test.php',
  data: {data:"data"}
});
$.ajax({
  type: "PUT",
  url: '../Server/test.php',
  data: {data:"data"}
});
$.ajax({
  type: "GET",
  url: '../Server/test.php',
  data: {data:"data"}
});

php: 的PHP:

<?
echo $_SERVER['REQUEST_METHOD'];
?>

in Chrome the response was PUT, PUT, GET in Opera as expected POST, PUT, GET 在Chrome中,响应是预期的Opera中的PUT,PUT,GET,POST,PUT,GET

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PHP REQUEST_METHOD POST 变成 GET - PHP REQUEST_METHOD POST turns into GET 表单操作是post,但回显$ _SERVER [&#39;REQUEST_METHOD&#39;]显示get - Form action is post but echoing $_SERVER['REQUEST_METHOD'] shows get PHP在不使用$ _SERVER [&#39;REQUEST_METHOD&#39;]的情况下检测请求类型(GET,POST,PUT或DELETE) - PHP detecting request type (GET, POST, PUT or DELETE) without using $_SERVER['REQUEST_METHOD'] 将ajax发布到php返回$ _SERVER [&#39;REQUEST_METHOD&#39;] GET - ajax post to php returns $_SERVER['REQUEST_METHOD'] GET PHP $_SERVER[&#39;REQUEST_METHOD&#39;] 总是用 AJAX 帖子返回 GET - PHP $_SERVER['REQUEST_METHOD'] always returning GET with AJAX post 当REQUEST_METHOD是PHP中的GET时显示一个表单 - Show a form when REQUEST_METHOD is GET in PHP $ _SERVER [&#39;REQUEST_METHOD&#39;]以及同时POST和GET - $_SERVER['REQUEST_METHOD'] and simultaneous POST and GET 我对表单使用POST方法,但回显$ _SERVER [&#39;REQUEST_METHOD&#39;]结果为GET - I use POST method for form but echo $_SERVER['REQUEST_METHOD'] result is GET 在PHP中,iPhone POST请求始终被$ _SERVER [&#39;REQUEST_METHOD&#39;]视为GET - iPhone POST request is always seen as GET by $_SERVER['REQUEST_METHOD'] in PHP 使用$ _POST和$ _SERVER [&#39;REQUEST_METHOD&#39;]将数据以HTML格式插入mySQL - Inserting data into mySQL with HTML form using $_POST and $_SERVER['REQUEST_METHOD']
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM