LuisE LuisE - 3 months ago 14
PHP Question

$_POST is empty when using Postman but not when submiting forms

I want to use $_POST to send info from an App to a server, but when I test with Postman the $_POST doesn't get set. I am using XAMPP and php 5.6.23:

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


This, when set with Postman, will respond:

"It is not even set"


However, when sent with this:

<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 will give a satisfactory output:

it is set!


I've already set this in my php.ini:

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


It is kinda driving me nuts...

Edit: Screens of postman usage
Postman submit 1

and Get superglobal is working fine(just replacing POST for GET (however I need to use POST in volley request, unless I use a workaround, but that is not clean):
I just change POST for GET

Answer

You are actually sending the test as a query parameter (retrievable within your php script via $_GET['test']. To add POST data in Postman, click on the Body tab and add the data there.