How to retrieve form data sent via GET. When you submit a form through the GET method, PHP provides a superglobal variable, called $_GET. PHP uses this $_GET variable to create an associative array with keys to access all the sent information ( form data ). The keys is created using the element's name attribute values.
The data sent by POST method goes through HTTP header so security depends on HTTP protocol. By using Secure HTTP you can make sure that your information is secure. The PHP provides $_POST associative array to access all the sent information using POST method.
PHP $_POST is a PHP super global variable which is used to collect form data after submitting an HTML form with method="post".
$_GET is an array of variables passed to the current script via the URL parameters. $_POST is an array of variables passed to the current script via the HTTP POST method.
Read from php://input
. For example, you could use:
$rawdata = file_get_contents('php://input');
or
$rootNode = simplexml_load_file('php://input');
The alternative, using $HTTP_RAW_POST_DATA
, works, too - but it's slower and needs the PHP configuration always_populate_raw_post_data
.
Try the $HTTP_RAW_POST_DATA
variable or the php://input
stream.
http://us.php.net/manual/en/reserved.variables.httprawpostdata.php
$HTTP_RAW_POST_DATA should be available assuming the content-type of the request was not multipart/form-data
$HTTP_RAW_POST_DATA
or
php://input
You probably want to use the PHP input. Something like
$postText = trim(file_get_contents('php://input'));
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