Monday 10 December 2018

php - actionscript does not see changes to the textbox



Here is the relevant AS3 code:




public function processLogin ():void {


var phpVars:URLVariables = new URLVariables();

var phpFileRequest:URLRequest = new URLRequest("php/controlpanel.php");


phpFileRequest.method = URLRequestMethod.POST;


phpFileRequest.data = phpVars;

var phpLoader:URLLoader = new URLLoader();
phpLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
phpLoader.addEventListener(Event.COMPLETE, showResult);

phpVars.systemCall = "checkLogin";
phpVars.username = username.text;
phpVars.password = password.text;


phpLoader.load(phpFileRequest);


if(result_text.text == "Welcome")
{

gotoscenetwo();
}
else{
stop();

}

}
public function showResult (event:Event):void {

result_text.autoSize = TextFieldAutoSize.RIGHT;
result_text.text = "" + event.target.data.systemResult;

}



and my php code:




include_once "connect.php";



$username = $_POST['username'];
$password = $_POST['password'];



if ($_POST['systemCall'] == "checkLogin") {




$sql = "SELECT * FROM users WHERE username='$username' AND password='$password'";



$query = mysql_query($sql);



$login_counter = mysql_num_rows($query);



if ($login_counter > 0) {



while ($data = mysql_fetch_array($query)) {




$username = $data["username"];



print "systemResult=Welcome";



}



} else {



print "systemResult=The login details dont match our records.";




}



}




This is my mini project. My problem is if as3 finds a matching record in the MySQL database, my gotoscenetwo() function starts to work. Thank you for help.


Answer



Your if need to be inside the function showResult


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...