我有一个在 Adobe flash actionscript 3 中创建的表单,需要帮助来验证我所做的是否正确......我是 AS3 和 PHP 的新手,因此非常感谢任何帮助和解释......
这是我的 AS3 编码....
processing_mc.visible = false;
function checkComplete(evt:MouseEvent):void {
// Create A new URLVariables instance to store the variable
var phpVars:URLVariables = new URLVariables();
// Create a variable (e.g. candidate) to send
phpVars.userFirstName = firstname_txt.text;
phpVars.userLastName = lastname_txt.text;
phpVars.userNumber = number_txt.text;
phpVars.userEmail = email_txt.text;
phpVars.userMsg = msg_txt.text;
// Create a new URLRequest instance sending data to "ascom01.php"
var myRequest:URLRequest = new URLRequest("form.php");
// Send data using the POST method
myRequest.method = URLRequestMethod.POST;
var loader:URLLoader = new URLLoader();
loader.load(myRequest);
loader.addEventListener(Event.COMPLETE, response);
function response(e:Event):void
{
trace(loader.data);
}
if(!firstname_txt.length) {
status_txt.text = "Please enter your first name";
} else if(!lastname_txt.length) {
status_txt.text = "Please enter your last name";
} else if (!email_txt.length) {
status_txt.text = "Please enter your email";
} else if (!number_txt.length) {
status_txt.text = "Please enter your phone number";
} else {
}
}
// handler for the PHP script completion and return of status
function completeHandler(event:Event):void {
processing_mc.visible = false;
firstname_txt.text = "";
lastname_txt.text = "";
email_txt.text = "";
number_txt.text = "";
msg_txt.text = "";
status_txt.text = event.target.data.return_msg;
}
// Add event listener for submit button click
submit_btn.addEventListener(MouseEvent.CLICK, checkComplete);
这是我刚刚开始工作的 PHP 编码....
<?php
if(isset($_POST['userFirstName']) && isset($_POST['userLastName']) && isset($_POST['userEmail']) && isset($_POST['userNumber']) && isset($_POST['userMsg']))
{
$userFirstName=strip_tags($_POST['userFirstName']);
$userLastName=strip_tags($_POST['userLastName']);
$userEmail=strip_tags($_POST['userEmail']);
$userNumber=strip_tags($_POST['userNumber']);
$userMsg=strip_tags($_POST['userMsg']);
// connect with database.
$username="******";
$password="******";
$database="b-elite-fitness";
mysql_connect("localhost","$username","$password") or die (mysql_error());
mysql_select_db("$database") or die (mysql_error());
//query for inserting data in database.
$query="INSERT INTO `formdp` VALUES('NULL','".mysql_real_escape_string($userFirstName)."','".mysql_real_escape_string($userLastName)."','".mysql_real_escape_string($userEmail)."','".mysql_real_escape_string($userNumber)."','".mysql_real_escape_string($userMsg)."')";
if($query_run=mysql_query($query))
{
echo'Data inserted.';
} else {
die(mysql_error());
}
}
?>
任何人都可以帮助我了解两者之间的联系......我在网上查过,每个例子都不一样,无法理解它是如何工作的......
提前感谢DP