Sign In | Register Now About Bytes | Help | Site Map
Connecting Tech Pros Worldwide

Actionscript 3 with PHP

Question posted by: hott5hotj (Newbie) on December 28th, 2007 04:19 PM
I am trying to create an authentication using flash and AS3 as the underlying code using PHP as the server side scripting and mySQL to store the passwords. As I am a newbie I decided to start practicing using AS2 and tried to make the whole thing work. I could not get the flash interface to connect to the PHP to validate the database. I know that my PHP code worked because I can run a test through the browser and it would connect to the mySQL database. I decided then to opt to convert it to AS3. I could not get it to work is AS3 neither. Doing so changed the code so that I would have the PHP code holding the username and password as a test but I could not get this to work. It seems to me that my flash interface isnt connecting to the php script.

Here are my codes....any help would be great....I also enclose the error message I am now receiving which I do not understand why.


Expand|Select|Wrap|Line Numbers
  1. mcLogin.addEventListener(MouseEvent.CLICK, onClick);
  2.  
  3. function onClick(event:MouseEvent):void
  4. {
  5.     var variables = new URLVariables();
  6.     variables.username = tUsername.text;
  7.     variables.password = tPassword.text;
  8.  
  9.     var _request:URLRequest = new URLRequest("loginCheck.php");
  10.     _request.data = variables;
  11.     _request.method = URLRequestMethod.POST;
  12.  
  13.     var _loader:URLLoader = new URLLoader()
  14.     _loader.dataFormat = URLLoaderDataFormat.VARIABLES;
  15.     _loader.addEventListener(Event.COMPLETE, sendComplete);
  16.     _loader.addEventListener(IOErrorEvent.IO_ERROR, sendIOError);
  17.     _loader.load(_request);
  18. }
  19.  
  20. function sendComplete(event:Event):void
  21. {
  22.      tError2.text = "I'm sorry, it didnt load";
  23. }
  24.  
  25. function sendIOError(event:IOErrorEvent):void
  26. {
  27.     tError.text = "I'm sorry, it didnt load";
  28. }


Expand|Select|Wrap|Line Numbers
  1. <?php
  2. session_start();
  3. $username = $_POST['username'];
  4. $password = $_POST['password'];
  5.  
  6.  
  7. if($username == 'admin' && $password == 'admin123'){
  8. $_SESSION['loggedIn'] = true;
  9. echo 'login=success';
  10. }else{
  11. echo 'login=failure';
  12. }
  13. ?> 



Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
at Error$/throwError()

I dont have any ampersand so I dont know why this is thrown..

Any help would be great..

Thanks
rdourado's Avatar
rdourado
Newbie
1 Posts
July 14th, 2008
02:41 PM
#2

Re: Actionscript 3 with PHP
Try to change the path to php file to the full url like http://www.[domain].com/file.php

Reply
Reply
Not the answer you were looking for? Post your question . . .
189,325 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
Top Flash / Actionscript Forum Contributors