I wanted to know if it is possible to GET and POST on the same php page, for example
I want to send data to:
http://www.example.com/my.php
So first the GET
http://www.example.com/my.php?task=dosomething
and POST some $thexml = XML
to
http://www.example.com/my.php?task=dosomething
and then be able to access both in some code like (example)
// Example Code ============================
if($_GET["task"] == "dosomething"){
$mynewxml = $_POST["$thexml"];
}
//==========================================
Technically no, you cannot POST
and GET
at the same time. They are two different verbs, and you only get to make one during your request.
However, you will find that if you do a POST
and include parameters in the URL, such as yourscript.php?param1=somevalue¶m2=somevalue
, then both $_GET
and $_POST
will be populated with their respective data.
It would be wise to read up on how HTTP actually works. http://www.jmarshall.com/easy/http/
You should consider whether or not this is good system design on your part. A GET
is supposed to be for requests that don't change data on the server. A POST
can change data. Even though both can be implemented to do either, it is best to follow this common practice. You never know what some proxy or other program up the line will do with it otherwise.
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