发送AS3变量和使用PHP的电子邮件

发送AS3变量和使用PHP的电子邮件

本文介绍了发送AS3变量和使用PHP的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

 阵列(
)
 

。这里是我的codeS:

AS3 code:

  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;
 

按钮的code:

  myButton.addEventListener(MouseEvent.CLICK,仙);
功能森(事件:MouseEvent)方法:无效
{
navigateToURL(新的URLRequest(使用example.php),_self);
}
 

的PHP code:

 < PHP
$文字= var_export($ _ POST,真正的);
$到[email protected];
$主题=消息从PHP;
邮件($到,$主题,$文本,内容类型:text / plain的;字符集= UTF-8);
?>
 

那么,我究竟做错了什么?

解决方案

  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 = "[email protected]";
$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 );
};

这篇关于发送AS3变量和使用PHP的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 20:22