简体   繁体   English

$_POST 方法不起作用 $_GET 起作用

[英]$_POST Method doesn't work $_GET does

I simply cannot get the $_POST method to work.我根本无法使 $_POST 方法起作用。 Instead $_GET contains the data相反 $_GET 包含数据

I used Postman to test via POST and GET method: Screenshot我使用 Postman 通过 POST 和 GET 方法进行测试:截图

Server PHP Settings服务器 PHP 设置

Request: ***.rising-games.net/posttest.php?test=Something请求:***.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.您尝试使用 post 请求。 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但是您将test参数的值设置为不是请求的消息体而是获取参数http://www.rising-games.net/posttest.php?test=Something

Try this in Postman:在 Postman 中试试这个: 在此处输入图片说明

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

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