使用Postman时$ _POST为空,但在提交表单

时间:2016-08-19 17:41:55

标签: php post xampp postman

我想使用$ _POST将信息从应用程序发送到服务器,但是当我使用Postman测试时,$ _POST没有设置。我正在使用XAMPP和php 5.6.23:

<?php
if (isset($_POST["test"])){
$mystring=$_POST["test"];
echo $mystring;
}
else {
echo "it is not even set";
}
?>

当与Postman一起设置时,将回复:

"It is not even set"

然而,当发送时:

<html>
<body>
<form method="post" action="http://localhost/quetzal/test.php"> 
<input type="text" name="test" value="it is set!" /> 
<input type="submit" value="CHECK MY CODE" /> </form>
</body>
</html>

它会给出令人满意的结果:

it is set!

我已经在我的php.ini中设置了这个:

post_max_size=80M
variables_order="EGPCS"
upload_max_filesize=80M

这有点让我疯狂......

编辑:邮递员使用的屏幕 Postman submit 1

并且获取superglobal工作正常(只需替换POST为GET(但是我需要在截击请求中使用POST,除非我使用解决方法,但这不是干净的): I just change POST for GET

1 个答案:

答案 0 :(得分:2)

您实际上是将test作为查询参数发送(可通过$_GET['test']在您的php脚本中检索。要在Postman中添加POST数据,请点击Body标签并在那里添加数据。