我正在尝试使用联系表格开发一个Flash网站。
我的as3代码:
processing_mc.visible = false;
var variables:URLVariables = new URLVariables;
var varSend:URLRequest = new URLRequest("form_parse.php");
varSend.method = URLRequestMethod.POST;
varSend.data = variables;
var varLoader:URLLoader = new URLLoader();
varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
varLoader.addEventListener(Event.COMPLETE, completeHandler);
function completeHandler(event:Event):void {
processing_mc.visible=false;
name_txt.text="";
email_txt.text="";
msg_txt.text="";
//load response on php here
status_txt.text="In submit button";
status_txt.text = event.target.data.return_msg;
}
//add event listener to Submit button
submit_btn.addEventListener(MouseEvent.CLICK, ValidateAndSend);
//function validate and send
function ValidateAndSend(event:MouseEvent):void{
//validate fields
if(!name_txt.length){
status_txt.text="Please enter your Name";
} else if(!email_txt.text){
status_txt.text="Please enter your E-mail address";
} else if(!msg_txt.text){
status_txt.text="Please enter your Message";
} else {
//all is good, send data to php
processing_mc.visible=true;
//ready the variables to send
variables.userName = name_txt.text;
variables.userEmail = email_txt.text;
variables.userMsg = msg_txt.text;
// send the data to php now.
varLoader.load(varSend);
}//close for error handling
}//close validate and send function
PHP代码:
<?php
$senderName =$POST['userName'];
$senderEmail =$POST['userEmail'];
$senderMsg =$POST['userMsg'];
$senderName =stripslashes('userName');
$senderEmail =stripslashes('userEmail');
$senderMsg =stripslashes('userMsg');
$to="gidwani.hina14@gmail.com";
$from="$senderEmail";
$subject="enquiry";
$message=" Enquiry from:
Name:$senderName
Email:$senderEmail
The message sent :
Message:$senderMsg";
$headers= "From:$from\r\n";
$headers= "Content-type:text\r\n";
$to= "$to";
mail($to,$subject,$message,$headers);
$my_msg="Thanks $senderName,your data has been sent";
print"return_msg=$my_msg";
exit();
?>
我收到了一个错误:
TypeError:错误#2007:参数文本必须为非null。 在flash.text :: TextField / set text() 在AS3_PHP_Components_Form_fla :: wholeForm_1 / completeHandler() at flash.events::EventDispatcher/flash.events:EventDispatcher ::: dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() 在flash.net::URLLoader/flash.net:URLLoader::onComplete()
有什么问题?