I'm trying to read a post request sent from a client using PHP
whether they pass variables or not. What I want is to read the post data. I have tried using, the following without any luck:
echo file_get_contents('php://input');
I have tried sending the post request to http://posttestserver.com/ and the HTTP Post
returns 200
and shows the post data sent to it.
How do I go about this using php?
You can read the post data from the $_POST
variable. If you want to know which keys the array holds, use array_keys():
$postKeys = array_keys($_POST);
Alternatively, you could use foreach
to scan the array:
foreach ($_POST as $key => $value) {
echo "Key: $key; Value: $value\n";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With