Coding in AS2
Using Flash CS4
I have a project where I am using sendAndLoad to send a username and password, once verified the php sends back the account number.
The code works fine when the php is:
<?php
echo("account=18");
?>
But when I add in the code to check the database and then return the account number the load part of the function doesn’t load.
Here is the flash code:
var loginSend:LoadVars = new LoadVars();
loginSend.emailEntry = emailEntry;
loginSend.pass = boxLogin.txtPassword.text;
var loginresponse:LoadVars= new LoadVars();
loginresponse.onLoad = loginLoaded;
function loginLoaded(success:Boolean):Void {
trace("login Loaded");
if ( success ) {
trace("login result: "+loginresponse.account);
trace(loginresponse);
userID=loginresponse.account;
//favorite_xml.load(xmlfavoritesfile);
//feature_xml.load(xmlfile);
boxLogin._visible=false;
} else {
trace("file not found");
}
}
loginSend.sendAndLoad("logincheck.php", loginresponse, "GET");
The response I am getting from the trace is the following:
%0Aaccount=18&onLoad=%5Btype%20Function%5D
I changed from POST to GET so I could easily check what the code was outputing in the browser. In the browser the everything looks good.
Below is the PHP code:
<?php
$username = $_GET['emailEntry'];
$password = md5($_GET['pass']);
include 'openDB.php';
$sql = "select * from users where username='$username' and password='$password'";
$query = mysql_query($sql) or die('error=$sql');
$row = mysql_fetch_array($query);
$a_id = $row['account'];
$num = mysql_num_rows($query);
if( $num == 0 )
{
echo("account=0");
exit();
}
else
{
$now = date("d/m/y : H:i:s", time());
$sql = "UPDATE users set last_login = '$now' where account = $a_id";
mysql_query($sql) or die("error=$sql");
echo("account=$a_id");
}
?>
Anybody have a clue what is causing this not to load?