Please help me with the script

i’m new to this, so i’m facing some problems. i’m trying to make a game…

the rules are like this:

  1. when entering the game, the players have to input their name and id and database updating their name, id and first level completed.
  2. if their id already exists they can’t enter into the game [in the first level]
  3. in the second level the script will check, if their id is exists and first level is completed, they can continue and the database will updated as the second level is completed.
    4 third level will check if id exists and second level is completed they can play and database will be updated.

seems my php codes are ok, but i can’t stop playing the players form playing the game.

problems are:

  1. if the id exists, still they can play the first level though data isn’t updating their data once again.
    2 in second level, if the id isn’t exists still they can play and database isn’t updating. not updating is ok, but i have to make them stop in that part, which means they didn’t finish the first level.
  2. same thing goes for the third level [like second level]

my first level actionscript is like this:

stop();

var lvSend:LoadVars = new LoadVars();
var lvReceive:LoadVars = new LoadVars();

mcID.tInput.restrict = “0-9”; //as trying to put a none-integer in age column in mySQL will cause an error

mcRegister.onRelease = function() {
var valid:Boolean = validateForm();

if(valid){
//gather information and put in loadvars object
lvSend.username = mcName.tInput.text;
lvSend.employeeid = mcID.tInput.text;
lvSend.dayone = "yes";

//send information php script for insertion into database
lvSend.sendAndLoad("check.php", lvReceive, "POST");
_root.gotoAndPlay("proceed");
}else{
    alert("Please complete all fields");    
}
//-------------------------------
_root.user = mcName.tInput.text;
//-------------------------------

};

lvReceive.onLoad = function(success:Boolean) {
if (success) {
if(this.result == “idExists”){
alert(“This employee ID already exists in the database. Please choose another”);
}else if (this.result == “success”) {
tMessage.text = “Thank you for registering. Your password has been sent to your email address”;
clearTextFields();
} else {
tMessage.text = “I’m sorry there has been an error with your registration”;
}
}
};

function validateForm():Boolean{
if(mcName.tInput.text == “” || mcID.tInput.text == “”){
return false;
}
return true;
}

function clearTextFields():Void{
mcName.tInput.text = “”;
mcID.tInput.text = “”;

}

//function which give javascript alerts – convenient for debugging when playing movie in a browser
//or even just alerting the user with javascript prompts when needed.
function alert(message:String):Void{
getURL(“javascript:alert(’”+message+"’);");
}

first level php code is:

<?php
//--------------------MYSQL DETAILS ---------------------------------------//

//mysql details
require_once(“dbDetails.php”);

//------------------GATHER FORM DETAILS ---------------------------------//

$username = $_POST[‘username’];
$employeeid = $_POST[‘employeeid’];
$dayone = $_POST[‘dayone’];

//----first check the employee ID does not exist already
$SQL = “SELECT * FROM members_tbl WHERE employee_id =’”.$employeeid."’";
$rs = mysql_query($SQL,$conn);
$numRows = mysql_num_rows($rs);
if($numRows > 0){
echo ‘&result=idExists&’;
exit();//abort php script
}

//--------insert into database------------------------------//

$insertSQL = “INSERT INTO members_tbl(user_name, employee_id, day_one) VALUES (’$username’, ‘$employeeid’, ‘$dayone’)”;
echo ‘&result=success&’;
$rs = mysql_query($insertSQL,$conn);

?>

second level actionscript is:

stop();

var lvSend:LoadVars = new LoadVars();
var lvReceive:LoadVars = new LoadVars();

mcID.tInput.restrict = “0-9”; //as trying to put a none-integer in age column in mySQL will cause an error

mcRegister.onRelease = function() {
var valid:Boolean = validateForm();

if(valid){
//gather information and put in loadvars object
lvSend.username = mcName.tInput.text;
lvSend.employeeid = mcID.tInput.text;
lvSend.daytwo = "yes";

//send information php script for insertion into database
lvSend.sendAndLoad("checktwo.php", lvReceive, "POST");
_root.gotoAndPlay("proceed");
}else{
    alert("Please complete all fields");    
}
//--------------------------------
_root.user = mcName.tInput.text;
//-------------------------------

};

lvReceive.onLoad = function(success:Boolean) {
if (success) {
if(this.result == “idExists”){
alert(“It seems you haven’t completed the 1st level yet.”);
}else if (this.result == “success”) {
tMessage.text = “Thank you for playing. Exciting prized are waiting for you”;
clearTextFields();
} else {
tMessage.text = “I’m sorry there has been an error with your playing”;
}
}
};

function validateForm():Boolean{
if(mcName.tInput.text == “” || mcID.tInput.text == “”){
return false;
}
return true;
}

function clearTextFields():Void{
mcName.tInput.text = “”;
mcID.tInput.text = “”;

}

//function which give javascript alerts – convenient for debugging when playing movie in a browser
//or even just alerting the user with javascript prompts when needed.
function alert(message:String):Void{
getURL(“javascript:alert(’”+message+"’);");
}

second level php code is:

<?php
//--------------------MYSQL DETAILS ---------------------------------------//

//mysql details
require_once(“dbDetails.php”);

//------------------GATHER FORM DETAILS ---------------------------------//

$username = $_POST[‘username’];
$employeeid = $_POST[‘employeeid’];
$dayone = $_POST[‘dayone’];
//$daytwo = $_POST[‘daytwo’];

//----first check the employee ID does not exist already
$SQL = “SELECT * FROM members_tbl WHERE employee_id =’”.$employeeid."’";

$rs = mysql_query($SQL,$conn);
$numRows = mysql_num_rows($rs);
if($numRows > 0){
echo ‘&result=idExists&’;
echo ‘&resulttwo=dayoneCompleted&’;
//exit();//abort php script
}

//--------insert into database------------------------------//

$query = “UPDATE members_tbl SET day_two= ‘yes’ WHERE employee_id=’$employeeid’”;
echo ‘&result=success&’;
$rs = mysql_query($query);

?>

in my mySQL database there are 5 datafield and they are like this:

user_name, employee_id, day_one, day_two, day_three

please help me with this.

Thanks in advance.