Imagine that I have a form in a flash application with two fields, input1 and input2. And when the user finish filling this form, it goes to a php page.
At the moment, I’m using the $_GET method to send the data.
Like this:
var request:URLRequest;
request = new URLRequest("http://site.com/page.php?data1="+input1.text+"&data2="+input2.text);
navigateToURL(request);
And in the php code:
$_GET["data1"];
$_GET["data2"];
But this way, the information stays in the URL. How can I send this via $_POST?
in AS 3 the URLRequest class you use to specify your request has a method property which can be used to set he HTTP option for submission method, you’ll need to set it to POST using URLRequestMethod constant POST for perfect form or you could use a “POST” string.
You can find a comprehensive example on snipplr
so in a nutshell:
When using Adobe Air You’d need to use the URLLoader class instead of navigateToURL() because of the following tidbit:
Basically whenever you want to use POST set method correctly, as also indicated by the documentation for navigateToUrl:
next in php you’d be receiving the variable in the superglobal $_POST array, where you could access it as such: