Report abuse

login.addEventListener(MouseEvent.MOUSE_DOWN, sender);
function sender(evt:Event) {
	if (tID.text!="" && tPassword.text !="") {
		
		var loginData:URLRequest = new URLRequest("login3.php");
		loginData.method = URLRequestMethod.POST;
		var variables:URLVariables = new URLVariables();
		variables.Username = tID.text;
		variables.Password = tPassword.text;
		loginData.data = variables;

		var loader:URLLoader = new URLLoader();
		loader.dataFormat = URLLoaderDataFormat.VARIABLES;
		loader.addEventListener(Event.COMPLETE, dataOnLoad);
		try {
			loader.load(loginData);
			trace("Successfully loaded data!");
		} catch (error:Error) {
			trace("Unable to load URL");
		}

	} else {
		status_txt.text = "Empty Fields!";
	}
}
function dataOnLoad(evt:Event) {
//here, the php should return "writin=Access granted" or else, if the database query returned that the user is exist, and the password was correct

	if (evt.target.data.writing == "Access granted") {
		status_txt.text = "Access granted!";

//this clip is just a transition i put to make logging in more smooth

		MovieClip(this.parent).blackOut.gotoAndPlay(2);
		MovieClip(this.parent).blackOut.addEventListener(Event.ENTER_FRAME, entersite);
	} else {
		status_txt.text = "Access denied!";
	}
}