Not yet rated

Problem

I am trying to create a login page using Flash CS4 & AS 3. The problem I am facing is that I cannot POST the information to a separate PHP page. What I am trying to do is use the Flash page as the log in and POST the data to a separate PHP page for processing. I am not looking to have data returned to the Flash page...rather, when the user clicks the Submit button I want them to be redirected to the PHP page that has its own authentication. Here's my old code... AS 2.0 code onClipEvent (load) { _root.btnSubmit.addEventListener("click", btnSubmit_clicked); function btnSubmit_clicked() { c = new LoadVars(); c.theName = _root.txtUrName.text; c.send("check_answers.php", "_self", "POST"); } // END OF FUNCTION } AS 3.0 code (so far) btnSubmit.addEventListener(MouseEvent.CLICK, btnSubmit_clicked); function btnSubmit_clicked(event:MouseEvent):void { txtStatus.text = "You are being logged on..."; } Please help!

Solution

Use URLRequest and URLVariables.

Detailed explanation

This can be accomplished using URLRequest and URLVariables. Try the following function:

 

function submitForm(e:MouseEvent):void{ 
  var urlRequest:URLRequest = new URLRequest("yourProcPage.php"); 
  var urlVariables:URLVariables = new URLVariables(); 
  urlRequest.method = URLRequestMethod.POST; 
  urlRequest.data = urlVariables; 
  urlVariables.userName = userNameInput.text; 
  urlVariables.password = passwordInput.text; 
  navigateToURL(urlRequest, "_self"); 
}


+
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

Report abuse

Related recipes