Is it actually possible to get data in both $_GET and $_POST? And how does this relate to what is in $_REQUEST?
With Ajax you can send data to a PHP script via GET and POST in the same request. The process is similar to sending data through the POST, it's actually the same, being only applied a "trick".
$_GET, and $_POST are array variables of PHP which are used to read submitted data by HTML form using the get and post method accordingly.
Difference is: $_GET retrieves variables from the querystring, or your URL.> $_POST retrieves variables from a POST method, such as (generally) forms.
In some applications, the HTTP methods GET and POST can be used interchangeably. For example, the application may expect a POST request, and the frontend will also send the data in a POST request, but if the request is tampered with, the data will also be accepted in a GET request.
Yes, it's possible. Consider a form like this:
<form action="foobar.php?a=123&b=456" method="post">
<input type="text" name="a" value="llama">
<input type="text" name="b" value="duck">
<input type="submit" name="go" value="Submit me!">
</form>
On submitting this form, $_GET["a"] == "123"
, $_GET["b"] == "456"
, $_POST["a"] == "llama"
, $_POST["b"] == "duck"
, and $_POST["go"] == "Submit me!"
.
How this relates to the $_REQUEST
superglobal depends on the value of the request_order
(or the older variables_order
) PHP configuration setting, as the php.ini documentation explains.
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