我正在我的网站上处理包含输入框和提交按钮的 Flash 内容。用户应该在输入框中输入一个问题的答案,当他点击提交时,答案应该发送到一个电子邮件地址。问题是,当用户输入答案时,我会收到一封空电子邮件。这是我的代码:
文本框代码:
var myData:URLVariables = new URLVariables();
myData.answer = "";
var myRequest:URLRequest = new URLRequest("MyDomain/..../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("MyDomain/..../example.php"), "_self");
}
这是PHP代码:
<?php
$answer = $_POST['answer'];
$to = "MyMail@example.com";
$subject="Message from php";
mail($to,$subject,$text,"Content-Type: text/plain; charset=utf-8");
?>
那么它有什么问题呢?