Connecting Tech Pros Worldwide Help | Site Map

Actionscript 3 with PHP

  #1  
Old December 28th, 2007, 05:19 PM
Newbie
 
Join Date: Oct 2007
Posts: 6
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. }
[PHP]<?php
session_start();
$username = $_POST['username'];
$password = $_POST['password'];


if($username == 'admin' && $password == 'admin123'){
$_SESSION['loggedIn'] = true;
echo 'login=success';
}else{
echo 'login=failure';
}
?> [/PHP]


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
  #2  
Old July 14th, 2008, 03:41 PM
Newbie
 
Join Date: Jul 2008
Posts: 1

re: Actionscript 3 with PHP


Try to change the path to php file to the full url like http://www.[domain].com/file.php
  #3  
Old June 10th, 2009, 08:12 PM
Newbie
 
Join Date: Jun 2009
Posts: 1

re: Actionscript 3 with PHP


I am having the same problem. Did you ever figure out a solution? I've been banging my head all week getting this to work. It seems as though the php script I have is not being executed. In my Event.COMPLETE event handler I can inspect the event.target.data and what I get back is the entire php script! Please help!
  #4  
Old August 13th, 2009, 04:52 PM
gopan's Avatar
Member
 
Join Date: Apr 2009
Location: Kochi (COK), India
Posts: 39

re: Actionscript 3 with PHP


Quote:
Originally Posted by porksoda View Post
I am having the same problem. Did you ever figure out a solution? I've been banging my head all week getting this to work. It seems as though the php script I have is not being executed. In my Event.COMPLETE event handler I can inspect the event.target.data and what I get back is the entire php script! Please help!
Are you sure that your server executes php scripts??
Try the url to php file in a browser...
  #5  
Old August 17th, 2009, 03:03 PM
Member
 
Join Date: May 2009
Posts: 81

re: Actionscript 3 with PHP


Whenever you make a PHP API for something, you should always craft manual requests and ensure the script itself is responding as expected. My guess is that your problem comes from server side. Do a few trace() calls and check the contents of the page you receive. If that doesn't help you, then get friendly with telnet or one of those fancy request crafting addons for FFox.
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatically formatting ActionScript with HTML Malk answers 1 August 27th, 2007 03:55 PM
Send value from Flash to database with PHP molle answers 2 June 5th, 2007 05:40 PM
Flash send value to database with PHP molle answers 1 June 4th, 2007 07:26 PM
Dynamic Maps with php?? Craig Storey answers 7 July 17th, 2005 01:40 PM