Sending POST data from Flash?

We are trying to send POST data from Flash to a PHP script, but it’s not working.


loadVariables(URLstring, "_root", "GET"); // this works when reading $_GET from PHP
loadVariables(URLstring, "_root", "POST"); // this doesn't work when reading $_POST from PHP

Any clues?

using the LoadVars() object is the newer and better way of doing this.


var sendInfo = new LoadVars();

//Load up all the variables you want to POST
sendInfo.myVar = "some string or something";
sendInfo.myOtherVar = "some other string or something";
sendInfo.myNumberVar = 22;

sendInfo.send("script.php", "_self","POST");

then you can access myVar, myOtherVar and myNumberVar as post variables in the file addressed by send()

We tried that, and Flash is now redirecting the browser to the specified PHP page with the data still as GET

:frowning:

try this instead. this will prevent the browser from actually going to the post page. I dont see why the data would still be GET…


var sendInfo = new LoadVars();

//Load up all the variables you want to POST
sendInfo.myVar = "some string or something";
sendInfo.myOtherVar = "some other string or something";
sendInfo.myNumberVar = 22;
sendInfo.sendAndLoad("script.php", sendInfo, "POST");


Ya, we can’t figure it out either. Even Safari’s activity window shows the URL with the query-string attached. It’s like the “POST” parameter doesn’t work at all.

Well I am on a PC and it works for me…

Maybe its a Mac problem? :wink:

Well I was hinting at that as a joke… but I really dont see why it should be a problem…

It really might be. I’ll let you guys know if I ever get it figured out over here. Thanks for the help!

why not try this thing on a PC? B’coz James is right, it does work on PC.

I can vouch too works fine on PC !
Just finished a project and its fine

So, there are 3 people using 3 different PCs saying that it works. I think that it is a problem on Mac, try it out on a PC Peter. Then you can holler at the MM forums & demand why its died up on poor ole Mac. :wink:

One thing is how are you testing this movie? Through a browser or through the flash development env.

When using Control > Test Movie, whether you specify POST or GET variables will always be sent as GET.

In addition Projector files cannot send a POST.

Your best bet is to test through a browser after publishing the movie. Or use $_REQUEST instead of $_GET or $_POST in the PHP script.

Testing through browser, but Safari only (no PCs here … yet)

And I won’t use $_REQUEST - that defeats the point. I might as well register_globals.

I still think that is so weird…
have you tried IE and Firefox on MAC to see if its any different?

after that, I would make a very simple swf that just posts some data and see if that works… maybe you have some code in your project that is somehow messing you up…

And I won’t use $_REQUEST - that defeats the point. I might as well register_globals.

I would tend to disagree. In fact PHP is one of the only languages out there that distinguishes between the two, when dealing with form data.

register_globals is more about sloppy coding and not instantiating variables, etc. etc.

Well, then we just disagree. ASP has Request.QueryString and Request.Form - same separation as far as I’m concerned. The point is, one should never accept GET (query-string) data as though it came through a POST request.

I agree knowledge of where data is coming from is essential. However sometimes in order to make things cross-browser compliant to include browsers such as Safari, one must make certain sacrifices. If one is concerned enough about where data has come from, one might think about using a server confirguration to only allow requests to one’s page from certain other pages in the same subdomain.

the solution: eliminate apple :slight_smile: