我正在使用PHP,AS3和MySQL。我有一个问题,每当我尝试登录与PHP和MySQL集成的AS3登录系统时,它会说"登录详细信息与我们的记录不符。"
我绕过MySQL并手动更改密码,然后就可以了! 但问题是,只要有人注册帐户,数据就会被发送到我的MySQL数据库。但每当有人试图使用该数据登录时,它都无法工作。但是,如果我们在MySQL内部手动更改密码,它就会起作用。它是Flash中的一些文本错误还是从flash发送到MySQL的奇怪东西?
这是PHP代码:
<?php
include_once("connect.php");
$username = $_POST['username'];
$pass = $_POST['pass'];
$userbio = $_POST['userbio'];
$email = $_POST['email'];
$usercheck = mysql_query("SELECT * FROM users WHERE email = '$email'");
if(mysql_num_rows($usercheck) > 0){
exit("result_message=Email is in use");
} else {
$sql = "INSERT INTO users (username, pass, user_bio, email) VALUES ('$username', '$pass', '$userbio', '$email')";
mysql_query($sql) or exit("result_message=Error");
exit("result_message=Success");
}
?>
这是AS3注册码:
import flash.display.*;
import flash.events.*;
import flash.net.*;
register_button.addEventListener(MouseEvent.MOUSE_DOWN, checkForm);
MovieClip(root).RegBG.username_text.text = "";
password_text.text = "";
email_text.text = "";
/*
validate the user's input
*/
function checkForm (e:MouseEvent):void {
if (MovieClip(root).RegBG.username_text.text != "" && password_text.text != "" && email_text.text != "") {
sendForm();
} else {
result_text.text = "Please fill in all the fields!";
}
}
/*
function we use to send the form
*/
function sendForm ():void {
/*
we use the URLVariables class to store our php variables
*/
var phpVars:URLVariables = new URLVariables();
phpVars.username = MovieClip(root).RegBG.username_text.text;
phpVars.pass = password_text.text;
phpVars.email = email_text.text;
/*
we use the URLRequest method to get the address of our php file and attach the php vars.
*/
var urlRequest:URLRequest = new URLRequest("http://lumosityentertainment.hostei.com/phpcodes/register.php");
/*
the POST method is used here so we can use php's $_POST function in order to recieve our php variables.
*/
urlRequest.method = URLRequestMethod.POST;
/*
this attaches our php variables to the url request
*/
urlRequest.data = phpVars;
/*
we use the URLLoader class to send the request URLVariables to the php file
*/
var urlLoader:URLLoader = new URLLoader();
urlLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
/*
runs the function once the php file has spoken to flash
*/
urlLoader.addEventListener(Event.COMPLETE, showResultreg);
/*
we send the request to the php file
*/
urlLoader.load(urlRequest);
}
/*
function to show result
*/
function showResultreg (e:Event):void {
result_text.text = "" + e.target.data.result_message;
}
以下是AS3登录代码:
import flash.events.MouseEvent;
function processLogin():void {
/*
variables that we send to the php file
*/
var phpVars:URLVariables = new URLVariables();
/*
we create a URLRequest variable. This gets the php file path.
*/
var phpFileRequest:URLRequest = new URLRequest("http://lumosityentertainment.hostei.com/phpcodes/controlpanel.php");
/*
this allows us to use the post function in php
*/
phpFileRequest.method = URLRequestMethod.POST;
/*
attach the php variables to the URLRequest
*/
phpFileRequest.data = phpVars;
/*
create a new loader to load and send our urlrequest
*/
var phpLoader:URLLoader = new URLLoader();
phpLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
phpLoader.addEventListener(Event.COMPLETE, showResult);
/*
now lets create the variables to send to the php file
*/
phpVars.systemCall = "checkLogin";
phpVars.username = username.text;
phpVars.pass = password_show.text;
/*
this will start the communication between flash and php
*/
phpLoader.load(phpFileRequest);
phpLoader.addEventListener(Event.COMPLETE, showResult);
}
PlayButton.addEventListener(MouseEvent.MOUSE_DOWN, checkLogin);
function checkLogin(E:MouseEvent): void {
if (username.text == "" || password_show.text == "") {
if (username.text == "") {
username.text = "Enter your username";
}
if (password_show.text == "") {
password_show.text = "Enter your password";
}
} else {
processLogin();
}
}
function showResult (event:Event):void {
charactername = username.text
result_text.text = "" + event.target.data.logincheck;
if(result_text.text == "The login details does not match our records."){
trace("Login Failed");
} else {
result_text.text = "Success. Please wait till game is released to play!";
//LOADING FROM PHP
}
}
当我进入注册帐户框架时,我收到此错误:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at FantasyDreamsAS3_fla::MainTimeline/frame2()
at flash.display::Sprite/constructChildren()
at flash.display::Sprite()
at flash.display::MovieClip()
at FantasyDreamsAS3_fla::BGCharacterCreate_22()
at flash.display::MovieClip/gotoAndStop()
at FantasyDreamsAS3_fla::MainTimeline/gotomakechar()