0

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.

2
  • 1
    "My problem is if as3 finds a matching record in the MySQL database, my gotoscenetwo() function starts to work." - I don't understand what you're asking.... you need to be more specific. Commented Jun 14, 2013 at 15:29
  • i have login screen in flash, if username and password true,i want flash open the new page, "Harrison" solution way is correct but that not work in localhost i dont understand why Commented Jun 14, 2013 at 21:11

1 Answer 1

0

Your if need to be inside the function showResult

Sign up to request clarification or add additional context in comments.

2 Comments

thats work in flash thank you. but again not work in local server.
problem is fixed now thank you so much. that was security problem. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.