# Login Using Flash MX, PHP, and MySQL

**URL:** <https://forum.kirupa.com/t/login-using-flash-mx-php-and-mysql/229170>\
**Category:** Uncategorized\
**Created:** [June 14, 2007, 4:53pm UTC](https://forum.kirupa.com/t/login-using-flash-mx-php-and-mysql/229170 "2007-06-14T16:53:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![electricneil](https://avatars.discourse-cdn.com/v4/letter/e/3ec8ea/32.png) [@electricneil](https://forum.kirupa.com/u/electricneil)\
**Post date:** [June 14, 2007, 4:53pm UTC](https://forum.kirupa.com/t/login-using-flash-mx-php-and-mysql/229170/1 "2007-06-14T16:53:53Z")

</div>

Found this cool tutorial where you can log in to a secret section in a falsh movie using loadVariablesNum and php and mysql to check the user info is ok.

Got it to work fine…  
but when i try and use the actionscript/php in a different level/mc of the movie i cant get it to work.

Ive put all the flash code within an mc called logger

this is what i have so far, bearing in mind ive tried allsorts…

so you have a username and password and a submit button, the submit button has this script attached to it:

on (release, keyPress “\<Enter\>”) {  
if (user != “” && pass != “”) {

```
    status = "Begin Login Process - Wait...";
    loadVariablesNum("http://www.chungking.co.uk/newlogin.php", 0, "POST");
}

```

}

which is sent off to the PHP page:

//connect to database  
if ($user && $pass){  
include(‘locked/database.php’);

session\_start();  
// asign values to session  
$\_SESSION[username]=$user;

//make query  
$query = ("SELECT \* FROM phplist\_user\_user  
WHERE email=’{$\_POST[‘user’]}’  
AND email=(’{$\_POST[‘pass’]}’)  
") or die (mysql\_error());  
$result = mysql\_query( $query ) or die (“didn’t query”);

//see if there’s an EXACT match  
$num = mysql\_num\_rows( $result );  
if ($num == 1){  
print “logger.status=welcome $\_SESSION[username] You have succesfully logged in&\_global.checklog=1”;  
} else {  
print “logger.status=Sorry, But Your Email Address Did Not Match Our Records In Our Database, Have You Registered?&\_global.checklog=2”;  
}  
}  
?\>

the print from the php is then sent back to the flash movie and picked up by a status dynamic text field which displays the result:

welcome $\_SESSION[username] You have succesfully logged

all works great but cant get the check log bit to work which sends you to frame (1) or (2)

stop();

userinput.restrict=“a-zA-Z0-9-@-_-.";  
Selection.setFocus(userinput);  
passinput.restrict="a-zA-Z0-9-@-_-.”;  
status=“Enter your information and submit”;  
this.onEnterFrame = function () {  
\_global.checklog;  
if(global.checklog == 1){  
logger.gotoAndStop(2);  
}  
if(global.checklog == 2){  
logger.gotoAndStop(3);  
}  
}

tried making the variable checklog global tried changing the php to correspond with the level off the mc.

just cant suss it out

any ideas??

much appreciated.
