OK, my problem is simples. I want to be able to send an email directly from a Flash animation using an external php file. This email will have the datas I insert in a few text boxes.
In AS2 I had no problem doing this… AS3 is presenting me a chalenge.
Here is the code I have so far:
AS3
var loader:URLLoader = new URLLoader();
var req:URLRequest = new URLRequest("[email.php](http://www.martingunnarsson.se/flashtest/send.php)");
var variables:URLVariables;
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
req.method = URLRequestMethod.POST;
sender.addEventListener(MouseEvent.MOUSE_DOWN, sendForm);
function sendForm(evt:MouseEvent):void {
variables.theName = theName.text;
variables.theEmail = theEmail.text;
variables.theMessage = theMessage.text;
req.data = variables;
loader.load(req);
}
}
PHP
<?PHP
$theName = $_POST['theName'];
$theEmail = $_POST['theEmail'];
$theMessage = $_POST['theMessage'];
$to = "[EMAIL="email@email.com"]email@email.com[/EMAIL]";
$subject = "wathever subject";
$message = "Name: " . $theName;
$message .= "
Email: " . $theEmail;
$message .= "
Message: " . $theMessage;
$headers .= "From: $theEmail";
$headers .= "
Reply-To: $theEmail";
mail($to,$subject,$message,$headers);
?>
can some one find my mistake?