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.
[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.de code() 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
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.
Code:
mcLogin.addEventListener(MouseEvent.CLICK, onClick);
function onClick(event:MouseEvent):void
{
var variables = new URLVariables();
variables.username = tUsername.text;
variables.password = tPassword.text;
var _request:URLRequest = new URLRequest("loginCheck.php");
_request.data = variables;
_request.method = URLRequestMethod.POST;
var _loader:URLLoader = new URLLoader()
_loader.dataFormat = URLLoaderDataFormat.VARIABLES;
_loader.addEventListener(Event.COMPLETE, sendComplete);
_loader.addEventListener(IOErrorEvent.IO_ERROR, sendIOError);
_loader.load(_request);
}
function sendComplete(event:Event):void
{
tError2.text = "I'm sorry, it didnt load";
}
function sendIOError(event:IOErrorEvent):void
{
tError.text = "I'm sorry, it didnt load";
}
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.de code() 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
Comment