Im newbie to integrate Flash,php and mysql using xamp. I tried alot to rectify this bug but i cant do so because i dont knw whether the bug is in php page or the value is not passed to php.
This is my AS3 code :
public function processLogin ():void {
trace("inside the processlogin method");
var phpVars:URLVariables = new URLVariables();
var phpFileRequest:URLRequest = new URLRequest("controlpanel.php");
phpFileRequest.method = URLRequestMethod.POST;
var phpLoader:URLLoader = new URLLoader();
phpLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
phpLoader.addEventListener(Event.COMPLETE, showResult);
phpVars.Username = Username.text;
trace(phpVars.Username);
phpVars.password = password.text;
trace(phpVars.password);
phpFileRequest.data = phpVars;
trace("phpvariable"+phpVars);
phpLoader.dataFormat=URLLoaderDataFormat.TEXT;
phpLoader.load(phpFileRequest);
}
public function showResult (event:Event):void {
trace("show result");
result_text.autoSize = TextFieldAutoSize.LEFT;
result_text.text = "" + event.target.data.systemResult;
trace(event.target.data.systemResult);
}
}
This was the Output in console:
sucess
now im in checklogin
inside the processlogin method
raj
raj
phpvariableUsername=raj&password=raj
starts process login method
show result
ReferenceError: Error #1069: Property systemResult not found on String and there is no default value.
at actions::main/showResult()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
Corresponding Php page is
<html>
<body><?php
include("connect.php");
$username = $_POST['Username'];
$password = $_POST['password'];
$query = mysql_query("SELECT * FROM users WHERE username='$Username' AND password='$password'");
$login_counter = mysql_num_rows($query);
while ($data = mysql_fetch_array($query))
{
$userbio = $data['user_bio'];
print "systemResult=$userbio";
}
?>
</body>
</html>
The error message says it all –
event.target.datais a string – which has no propertysystemResult.Just take a look into
event.target.data, this should be the html code of the response.