I desperately need help sending variables from AS3 to PHP. I have been searching and trying for days to work it out but nothing seems to work. I have a swf which will be used for quotes, each part asks things like size, colour and other options. It has a summary part at the end that shows everything that has been added. I want to send these variables with there values to a PHP page to send an email. I can work out the PHP bit and I have tried several things to get the variables sent to the PHP but nothing seems to work.
I want to send the variables to php when the submit button is clicked, it goes to the test PHP page which should then print the variables but it is blank. I have searched the internet for days and then I have tried lots of adjustments but still can’t figure it out. I would really appreciate it if someone could check my code and let me know where I am going wrong. I am hoping the problem might be obvious to someone who knows more about it.
Here is the code I have at the moment:
ActionScript Code:
btnSubmit1.[COLOR=#000000]addEventListener[/COLOR][COLOR=#000000]([/COLOR]
MouseEvent.[COLOR=#000000]MOUSE_UP[/COLOR],
[COLOR=#993300]function[/COLOR][COLOR=#000000]([/COLOR]evt:MouseEvent[COLOR=#000000])[/COLOR]:[COLOR=#993300]void[/COLOR] [COLOR=#000000]{[/COLOR]
PHPSendData[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR]
[COLOR=#993300]var[/COLOR] myData:URLRequest = [COLOR=#993300]new[/COLOR] URLRequest[COLOR=#000000]([/COLOR][COLOR=#0000ff]"test.php"[/COLOR][COLOR=#000000])[/COLOR]
[COLOR=#993300]try[/COLOR] [COLOR=#000000]{[/COLOR]
navigateToURL[COLOR=#000000]([/COLOR]myData, [COLOR=#0000ff]"_self"[/COLOR][COLOR=#000000])[/COLOR]
[COLOR=#000000]}[/COLOR] [COLOR=#993300]catch[/COLOR] [COLOR=#000000]([/COLOR][COLOR=#993300]e[/COLOR]:[COLOR=#993300]Error[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#993300]trace[/COLOR][COLOR=#000000]([/COLOR][COLOR=#993300]e[/COLOR][COLOR=#000000])[/COLOR]
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]
[COLOR=#000000])[/COLOR]
[COLOR=#993300]function[/COLOR] PHPSendData[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR]:[COLOR=#993300]void[/COLOR]
[COLOR=#000000]{[/COLOR]
[COLOR=#993300]var[/COLOR] myData:URLRequest = [COLOR=#993300]new[/COLOR] URLRequest[COLOR=#000000]([/COLOR][COLOR=#0000ff]"test.php"[/COLOR][COLOR=#000000])[/COLOR]
myData.[COLOR=#000000]method[/COLOR] = URLRequestMethod.[COLOR=#000000]POST[/COLOR]
[COLOR=#993300]var[/COLOR] variables:URLVariables = [COLOR=#993300]new[/COLOR] URLVariables[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR]
variables.[COLOR=#000000]orderEmail[/COLOR] = txtEmailInput.[COLOR=#993300]text[/COLOR]
variables.[COLOR=#000000]orderType[/COLOR] = strTankType
variables.[COLOR=#000000]orderHeight[/COLOR] = numFinalHeight
variables.[COLOR=#000000]orderWidth[/COLOR] = numFinalWidth
variables.[COLOR=#000000]orderLength[/COLOR] = numFinalLength
variables.[COLOR=#000000]orderColour[/COLOR] = arrFinalColour[COLOR=#000000][[/COLOR]globals.[COLOR=#993300]data[/COLOR].[COLOR=#000000]varNumColour[/COLOR][COLOR=#000000]][/COLOR]
variables.[COLOR=#000000]orderInlet1[/COLOR] = strFinalInlet1
variables.[COLOR=#000000]orderInlet2[/COLOR] = strFinalInlet2
variables.[COLOR=#000000]orderOutlet1[/COLOR] = strFinalOutlet1
variables.[COLOR=#000000]orderOutlet2[/COLOR] = strFinalOutlet2
variables.[COLOR=#000000]orderOverflow1[/COLOR] = strFinalOverflow1
variables.[COLOR=#000000]orderOverflow2[/COLOR] = strFinalOverflow2
myData.[COLOR=#993300]data[/COLOR] = variables
[COLOR=#993300]var[/COLOR] loader:URLLoader = [COLOR=#993300]new[/COLOR] URLLoader[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR]
loader.[COLOR=#000000]dataFormat[/COLOR] = URLLoaderDataFormat.[COLOR=#000000]VARIABLES[/COLOR]
loader.[COLOR=#000000]addEventListener[/COLOR][COLOR=#000000]([/COLOR]Event.[COLOR=#000000]COMPLETE[/COLOR], doComplete[COLOR=#000000])[/COLOR]
loader.[COLOR=#993300]load[/COLOR][COLOR=#000000]([/COLOR]myData[COLOR=#000000])[/COLOR]
[COLOR=#000000]}[/COLOR]
[COLOR=#993300]function[/COLOR] doComplete[COLOR=#000000]([/COLOR]anEvent:Event[COLOR=#000000])[/COLOR]:[COLOR=#993300]void[/COLOR]
[COLOR=#000000]{[/COLOR]
response.[COLOR=#993300]text[/COLOR] = [COLOR=#0000ff]"POST Complete = "[/COLOR] + anEvent.[COLOR=#993300]target[/COLOR].[COLOR=#993300]data[/COLOR].[COLOR=#000000]submitted[/COLOR]
[COLOR=#000000]}[/COLOR]
Here is the PHP code for the test page:
<?php
$email=$_POST['orderEmail'];
echo "Email=" . "$email";
?>
I’m new to AS3 so not too sure about anything but I’m not even sure if I need the loader bit or the function doComplete but I have tried it with and without and it doesn’t make a difference.
Any help greatly appreciated, thanks.