1

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?

1 Answer 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 );
};
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks mate. I've been searching for a solution for a long time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.