dimanche 26 juin 2016

as3 - contact form not working

I know this question has been asked a couple of times, but I cant make a contact form using as3 and php i always get an "UnidentifiedIndex"error ,here is the code . PHP:

<?php
{
$to = "name@yourdomain.com";
$subject = ($_POST['senderName']);
$message = ($_POST['senderMsg']);
$message .= "\n\n---------------------------\n";
$message .= "E-mail Sent From: " . $_POST['senderName'] . " <" . $_POST['senderEmail']  . ">\n";
$headers = "From: " . $_POST['senderName'] . " <" . $_POST['senderEmail'] . ">\n";
if(@mail($to, $subject, $message, $headers))
{
echo "answer=ok";
} 
else 
{
echo "answer=error";
}
}
?>

Action Script:

submit_btn.addEventListener(MouseEvent.CLICK, sendMessage);
function sendMessage(e:MouseEvent):void
{
    var my_vars:URLVariables = new URLVariables();
    my_vars.senderName = name_txt.text;
    my_vars.senderEmail = email_txt.text;
    my_vars.senderMsg = message_txt.text;


var my_url:URLRequest = new URLRequest("mail.php");
my_url.method = URLRequestMethod.POST;
my_url.data = my_vars;

var my_loader:URLLoader = new URLLoader();
my_loader.dataFormat = URLLoaderDataFormat.VARIABLES;
my_loader.load(my_url);

name_txt.text = "";
email_txt.text = "";
message_txt.text = "Message Sent";

}

By the way i am completely new to PHP

And this code i got it from a website so it is not mine and i am using xampp to create the server to open the php file can u help me? And another question , Will this work on mobile if i keep the server running? Thanks,

Aucun commentaire:

Enregistrer un commentaire