Wednesday, April 20, 2011

AS3 Code: E-mail Form [PHP]

//php code in file called "email.php"
< ?php
$sendTo = $_POST["sEmail"];
$subject = $_POST["sSubject"];
$headers = "From: " . $_POST["sName"] . "<" . $_POST["sEmail"] . ">\r\n";
$headers .= "Reply-To: " . $_POST["sEmail"] . "\r\n";
$headers .= "Return-path: " . $_POST["sEmail"];
$message = "Sent From: " . $_POST["sTheirEmail"] . "\r\n" . $_POST["sMessage"];
mail
?>

//In Flash, create input text fields:
//name_txt (single line)
//email_txt (single line)
//subject_txt (single line)
//note_txt (multiline)

//create dynamic text field: feedback_txt
//create send_btn

var variables:URLVariables = new URLVariables();
var mailAddress:URLRequest = new URLRequest("email.php");

send_btn.addEventListener(MouseEvent.CLICK,onSubmit,false,0,true);
function onSubmit(e:Event):void{
    variables .sName = name_txt.text;
    variables .sTheirEmail = email_txt.text;
    variables .sEmail = "yourEmailAddress@email.com";
    variables .sMessage = variables.sName + " has sent this note:" + "\n\n" + note_txt.text;
    variables .sSubject = subject_txt.text;
   
    mailAddress.data = variables;
    mailAddress.method = URLRequestMethod.POST;
    sendToURL(mailAddress);
   
    feedback_txt.text = "Your note has been sent.";
}





0 comments:

Post a Comment