patishere 0 Newbie Poster

It always receive undefined. I'm almost two week working on this code. BTW the code is based on the tutorial on this site http://active.tutsplus.com/tutorials/actionscript/create-a-flash-login-system-using-php-and-mysql-part-1/

I modified it. Any help?

PHP CODE:

<?php
include_once "connect.php";
session_start();
$username = $_POST['username'];
if ($_POST["sysCall"] == "checkLogin") {
/*
The * means the query initally selects all the records in the database.
Then the query filters out any records that are not the same as what the user entered.
*/
$sql = "SELECT username FROM usertable";
$query = mysql_query($sql);
/*
This counts how many records match our query
*/
$login_counter = mysql_num_rows($query);
/*
if $login_counter is greater we send a message back to flash and get the data from the database
*/
	if ($login_counter > 0) 
	{
	/*
	we use a while loop to get the user's bio. mysql_fetch_array gets all the field's data for the particular record.
	*/
		while ($data = mysql_fetch_array($query)) { 
		/*
		use the print function to send values back to flash
		*/
		echo 'systemResult= Success?!?';
		}
	} 
	else 
	{
	echo 'systemResult= Fail?!?';
	}
}
?>

AS3 CODE:

package actions {
 
    /*
    always extend a class using movieclip instead of sprite when using flash.
    */
    import flash.display.MovieClip;
    import flash.events.*;
    import flash.net.*;
    import flash.text.*;

    /*
    create our class
    */
     public class reglogclass extends MovieClip {
	
        public function reglogclass ():void {
			
			trace("Success connection");
					 /*
            buttonMode gives the button a rollover
            */
			
            submit_button.buttonMode = true;
			submit_button.addEventListener(MouseEvent.CLICK, checksignin);
			username.text = "";
		
		}
		
		public function checksignin(e:MouseEvent):void
		{
			if(username.text=="")
			{
				trace("Username");
				result_text.text = "Please enter your name";
			}
			else 
			{	
			process();
			}
		}
public function process():void
{			var vars = new URLVariables();
			var phploader:URLLoader = new URLLoader();
			var phprequest:URLRequest = new URLRequest("php/reglog.php");
			
			phprequest.data = vars;
			phprequest.method = URLRequestMethod.POST;		
			trace("Processing . . .");
			vars.sysCall = "checkLogin";
			vars.systemCall = "checkLogin";
			vars.username = username.text;
			phploader.dataFormat = URLLoaderDataFormat.VARIABLES;
			phploader.addEventListener(Event.COMPLETE, onComplete);
			phploader.addEventListener(IOErrorEvent.IO_ERROR, sendIOError);
			phploader.load(phprequest);
}
 
function onComplete(e:Event)
{			var vars = new URLVariables();
			var phploader:URLLoader = new URLLoader();
			var phprequest:URLRequest = new URLRequest("h t t p : / / localhost/php/reglog.php");
			phprequest.data = vars;
			var retvalphp = e.target.data.systemResult;
			trace(vars.systemResult);
			result_text.text = "" + e.target.data.retvalphp;
			result_text.autoSize = TextFieldAutoSize.LEFT;
			var systemResult = e.target.data.systemResult;
			trace(systemResult);
			
			
}
			function sendIOError(event:IOErrorEvent):void
			{
				trace("Error Loading File");
			}
		
	}
}