Hi everyone,
Iam using CS4, AS3.0. And I am trying to connect my swf to PHP with not much luck. Instead of receiving what is in the print command I get the whole php-document back. It seems PHP is not executing at all. Can anybody help. (PS.: I don;t know much about php at all)
The following is just a very reduced random example that I am using to figure this out. It has no purpose, but to serve me as a test run, and that doesn’t work either.
Here is my php test code:
<?php>
$name=&_POST['user'];
$alter=&_POST['age'];
$userInf="$name";
$userInf .="idNum=1005";
if ($alter>18)
{
print $userInf;
}
?>
Here is my Actionscript Code (minus the texfield creation and all that):
function goPHP() {
var phpFile:String="http://localhost/geloest.php";//
var variables:URLVariables=new URLVariables ;
variables.user="Markus";
variables.age=36;
var urlRequest:URLRequest=new URLRequest(phpFile);
urlRequest.data=variables;
urlRequest.method=URLRequestMethod.POST;
var testloader:URLLoader=new URLLoader();
testloader.addEventListener(Event.COMPLETE,receiveMSG);
testloader.load(urlRequest);
}
function receiveMSG(e:Event):void{
var urlLoader:URLLoader = URLLoader(e.target);
var args:URLVariables =new URLVariables(urlLoader.data);
generalTxtBox.text=args.toString();
post();
}
function post(){
addChild(generalTxtBox);
}
I get the following result in my text box:
%3C%3Fphp%3E%0D%0A%24name=&%5FPOST%5B%27user%27%5D%3B%0D%0A%24alter=&%5FPOST%5B%27age%27%5D%3B%0D%0A%0D%0A%24userInf=%22%24name%22%3B%0D%0A%24userInf%20%2E%3D%22idNum%3D1005%22%3B%0D%0A%0D%0Aif%20%28%24alter%3E18%29%0D%0A%7B%0D%0Aprint%20%24userInf%3B%0D%0A%7D%0D%0A%0D%0A%3F%3E
When I change
generalTxtBox.text=args.toString();
to
generalTxtBox.text=args.userInf.idNum;
the output window states that it is null
Pleeeeease help.