Copy link to clipboard
Copied
I am new to talking to PHP.
Trying to test sending data to a .php page both on a localhost server and on a remote server
I am trying following code:
AS3:
<?php
echo $_POST["username"]."post";
echo $_POST["amount"]."post";
echo $_GET["username"]."get";
echo $_GET["amount"]."get";
echo "hello world 808080";
?>
When sending to the localhost server I am getting an HTTPStatus of 200 back - suggesting something is working.
If I set loader.dataFormat = URLLoaderDataFormat.TEXT; to URLLoaderDataFormat.VARIABLES
I get an error:
Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
which suggests that when I use URLLoaderDataFormat.TEXT; that the data is being sent.
However I can't get the .php page to update.
Any help greatly appreciated.
Best Tommy Banana
Copy link to clipboard
Copied
So we have tested the .PHP page and it works fine receiving a GET message from html.
eg clicking on the link
ourserver/testtom.php?username=TESTUSER&amount=123
gets the variables displayed on the php page in the GET section using the php code above.
So the problem is in getting the .swf file to talk to the .php correctly.
Copy link to clipboard
Copied
So in case anyone else ends up here. This code worked:
So now I have the POST method working from AS3 to PHP and getting data back I can now try and work out how
to build the thing I need.... using JSON!
NB For it to work I needed to have both the .php and .swf file in the same directory online and not to use an absolute URL.
Copy link to clipboard
Copied
I tell a lie - it does work with an absolute URL!