简体   繁体   中英

$_POST Method doesn't work $_GET does

I simply cannot get the $_POST method to work. Instead $_GET contains the data

I used Postman to test via POST and GET method: Screenshot

Server PHP Settings

Request: ***.rising-games.net/posttest.php?test=Something

<?php
echo "Request method: " . $_SERVER['REQUEST_METHOD'] . "<br><br>";

//-------------------------------------------
//  POST output
//-------------------------------------------
if (isset ($_POST ["test"]))
    echo "Post 'Test' is: " . $_POST ['test'] . "<br>";
else
    echo "Post 'test' is empty!<br>";

//-------------------------------------------
//  Get output
//-------------------------------------------
if (isset ($_GET ["test"]))
    echo "Get 'Test' is: " . $_GET ['test'] . "<br>";
else
    echo "Get 'test' is empty!<br>";

//-------------------------------------------
//  Request output
//-------------------------------------------
if (isset ($_REQUEST ["test"]))
    echo "Request 'Test' is: " . $_REQUEST ['test'];
else
    echo "Request 'test' is empty!";

?>

You try to use post request. But you set value of test parameter not to message body of request but to get parameter http://www.rising-games.net/posttest.php?test=Something

Try this in Postman: 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM