更新时间:2022-11-28 10:37:38
myButton.addEventListener(MouseEvent.CLICK,仙);
功能森(事件:MouseEvent)方法:无效
{
VAR的myData:使用URLVariables =新的URLVariables();
myData.answer = answer.text;
VAR myRequest:的URLRequest =新的URLRequest(使用example.php);
myRequest.data = myData的;
myRequest.method = URLRequestMethod.POST;
VAR装载机:的URLLoader =新的URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.load(myRequest);
};
I'm working on a flash content on my website that contains an input box and a submit button. The user should put an answer of a question in the input box and when he clicks on submit, the answer should be sent to an email address. The problem is, when a user enters an answer, I receive an email that contains :
array (
)
. Here are my codes:
AS3 Code:
var myData:URLVariables = new URLVariables();
myData.answer = answer.text;
var myRequest:URLRequest = new URLRequest("example.php");
myRequest.data = myData;
myRequest.method = URLRequestMethod.POST;
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
The button's code:
myButton.addEventListener(MouseEvent.CLICK, sen) ;
function sen(Event:MouseEvent):void
{
navigateToURL( new URLRequest("example.php"), "_self");
}
The PHP code:
<?php
$text = var_export($_POST, true);
$to = "webhosting4@outlook.com";
$subject="Message from php";
mail($to,$subject,$text,"Content-Type: text/plain; charset=utf-8");
?>
So, what am I doing wrong?
myButton.addEventListener(MouseEvent.CLICK, sen) ;
function sen(Event:MouseEvent):void
{
var myData:URLVariables = new URLVariables();
myData.answer = answer.text;
var myRequest:URLRequest = new URLRequest("example.php");
myRequest.data = myData;
myRequest.method = URLRequestMethod.POST;
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.load( myRequest );
};