Passing variable from Flash to PHP [closed]

aenleague

New Member
\[quote\] Possible Duplicate:
Passing variable FROM flash to HTML/php \[/quote\]I am working on this project using Flash (Actionscript 3.0). Basically, it's a drag and drop application. After getting some user input I'll need to pass a variable using PHP to a MySQL server. This is the code I have come up with:Actionscript:\[code\]import flash.net.URLVariables;import flash.net.URLRequest;import flash.net.navigateToURL;import flash.events.MouseEvent;var urlVariables:URLVariables = new URLVariables;var pi:pizza=new pizza();var totalAmt:Number;totalAmt=pi.totalPrice;urlVariables.totalAmount = totalAmt;//"" contains what should be passed//urlVariables.password = "testpass";//""contains what should be passedvar urlRequest:URLRequest = new URLRequest("http://172.21.147.103/csc207/bcg2g2/customise.php");urlRequest.data = http://stackoverflow.com/questions/10563907/urlVariables;sendToURL(urlRequest)\[/code\]PHP:\[code\]<?php$total = $_GET["totalAmount"];//$pass = $_GET["password"];echo $total;//echo $userName."::".$pass;?>\[/code\]The variable I am ultimately sending to PHP is totalAmount. Could someone give some feedback on whether the code is right? The server can be accessed using a username and password. Does that have to be specified? If so, how should I do it?Thank you in advance!Edit: Thanks for the responses guys!I have made changes to the code accordingly:
import flash.net.URLVariables; import flash.net.URLRequest; import flash.net.URLLoader; import flash.net.URLRequestMethod; import flash.net.navigateToURL; import flash.events.MouseEvent;\[code\]var urlString:String = "http://172.21.147.103/csc207/bcg2g2/customise.php"; function Submit():void{ var requestVars:URLVariables = new URLVariables(); requestVars.totalAmt= 50; // Dummy data to be sent to php var urlRequest:URLRequest = new URLRequest(); urlRequest.url = urlString; urlRequest.method = URLRequestMethod.GET; urlRequest.data = http://stackoverflow.com/questions/10563907/requestVars; var loader:URLLoader = new URLLoader(); loader.dataFormat = URLLoaderDataFormat.TEXT; loader.addEventListener(Event.COMPLETE, loaderCompleteHandler);sendToURL(urlRequest) try { loader.load(urlRequest); } catch (error:Error) { // Handle Immediate Errors }}function loaderCompleteHandler(e:Event):void{ trace(e.target.data); // Response Text}\[/code\]The value still doesn't get reflected. Can I just check if I'm doing this right? I should be uploading the SWF file to the website I'm working on, is there anything else I should be doing? Also, the info about authentication was useful! But I'm confused as to whether I should be using it in the code.. Any advice/suggestions?
 
Back
Top