Using php and POST on the form, but request_method says it is GET

So, I have this form that I submit to a php script that echos $ _SERVER ['REQUEST_METHOD']. I donโ€™t know why, but even if I specify the POST method on the form, it always echoes 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>
+3
source share
1 answer

since I spent countless hours trying to fix the "REQUST_METHOD" error in PHP and didn't find anything useful on the Internet, this is my report on this issue: Chrome seems to have an error in version 30.0. 1599.101

my jquery test code is:

$.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:

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

in Chrome, the answer was PUT, PUT, GET in Opera, as expected, POST, PUT, GET

+1
source

All Articles