1

我正在我的网站上处理包含输入框和提交按钮的 Flash 内容。用户应该在输入框中输入一个问题的答案,当他点击提交时,答案应该发送到一个电子邮件地址。问题是,当用户输入答案时,我会收到一封电子邮件,其中包含:

array (
)

. 这是我的代码:

AS3 代码:

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;

按钮的代码:

myButton.addEventListener(MouseEvent.CLICK, sen) ;
function sen(Event:MouseEvent):void
{
navigateToURL( new URLRequest("example.php"), "_self");
}

PHP代码:

<?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");
?>

那么,我做错了什么?

4

1 回答 1

1
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 );
};
于 2013-06-08T22:23:00.173 回答