AS3 Contact Form with Php!

[FONT=Arial][SIZE=2][COLOR=#000000]Hello![/COLOR][/SIZE][/FONT]

[LEFT][FONT=Arial][SIZE=2][COLOR=#000000]I got the AS3 form to work using the form components tutorial http://www.developphp.com/Flash_tutorials/show_tutorial.php?tid=111. (Great tutorial!) The only problem that I’m having is trying to use a date chooser with the form. I don’t know the AS3 code for the date chooser or the php code to retrieve the date information and send it to me via email like the rest of the information that’s on the form. Please help! The date chooser is dynamic. (It has two .as files).[/COLOR][/SIZE][/FONT][/LEFT]

[LEFT][FONT=Arial]I was also trying to figure out how to use the global style for AS3. I looked at the AS3 documentation and didn’t quite understand it.[/FONT][/LEFT]

[LEFT][FONT=Arial][SIZE=2][COLOR=#000000]Thank you![/COLOR][/SIZE][/FONT][/LEFT]

[LEFT][COLOR=blue]AS3 Code for the form:[/COLOR][/LEFT]


[LEFT]stop();[/LEFT]
 
[LEFT]import fl.managers.StyleManager;
import flash.text.TextField;[/LEFT]
 
[LEFT]//Set Focus
stage.focus=f_nametxt;[/LEFT]
 
[LEFT]//global.style.setStyle("themeColor", "haloPurple");[/LEFT]
 
[LEFT]/*webDate.addEventListener(MouseEvent.CLICK, pick);
function pick(event:Event):void {
if (wedDate.isToday) {
  wedDate.text = wedDate.userwedDate;
  wedDate.isToday = false;
}
}*/[/LEFT]
 
 
[LEFT]f_nametxt.restrict = "A-Z a-z";
l_nametxt.restrict= "A-Z a-z,.";
addr_txt.restrict = "A-Z a-z.,-01234567890"
phone_txt.restrict = "-0123456789";
email_txt.restrict = "[email protected]_-01234567890";
clock_txt.restrict = " :01234567890ampmAMPM.";
msg_txt.restrict = "A-Z [email protected]!?_-01234567890";[/LEFT]
 
[LEFT]f_nametxt.tabIndex = 1;
l_nametxt.tabIndex = 2;
addr_txt.tabIndex = 3;
phone_txt.tabIndex = 4;
email_txt.tabIndex = 5;
wedDate.tabIndex = 6;
clock_txt.tabIndex = 7;
fullsvc_Cb.tabIndex = 8;
wkd_Cb.tabIndex = 9;
asst_Cb.tabIndex = 10;
msg_txt.tabIndex = 11;[/LEFT]
 
[LEFT]var variables:URLVariables = new URLVariables;[/LEFT]
 
 
[LEFT]//Build the varSend variable
var varSend:URLRequest = new URLRequest("form_CA.php");
varSend.method = URLRequestMethod.POST;
varSend.data = variables;[/LEFT]
 
 
[LEFT]//Build the varLoader variable
var varLoader:URLLoader = new URLLoader;
varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
varLoader.addEventListener(Event.COMPLETE, completeHandler);[/LEFT]
 
 
[LEFT]//Handler for the PHP script completion and return of data
function completeHandler(event:Event):void {[/LEFT]
 
[LEFT]f_nametxt.text = "";
l_nametxt.text = "";
addr_txt.text = "";
phone_txt.text = "";
email_txt.text = "";
clock_txt.text = "";
fullsvc_Cb.selected = false;
wkd_Cb.selected = false;
asst_Cb.selected = false;
msg_txt.text = "";
wedDate.text = "";[/LEFT]
 
 
[LEFT]//Load the response from PHP here
//trace("Hello World!");
msg_txt.text = event.target.data.return_msg;
}[/LEFT]
 
 
[LEFT]//AddEventListener for submit button click
submit_btn.addEventListener(MouseEvent.CLICK, ValidateAndSend);[/LEFT]
 
 
[LEFT]//function ValidateAndSend
function ValidateAndSend(event:MouseEvent):void {[/LEFT]
 
[LEFT]//Validate form fields[/LEFT]
 
[LEFT]if(!f_nametxt.length){
 f_nametxt.text = "Please enter First name !";
}else if(!l_nametxt.length){
 l_nametxt.text = "Please enter Last name !";
}else if(!addr_txt.length){
 addr_txt.text = "Please enter address!";
}else if(!phone_txt.length){
 phone_txt.text = "Please enter Telephone #!";[/LEFT]
 
[LEFT]}else if(!email_txt.length){
 email_txt.text = "Please enter Email address!";[/LEFT]
 
[LEFT]}else if(!clock_txt.length){
 clock_txt.text = "Time of the event!";
}else{[/LEFT]
 
[LEFT]//All is good, send the data now to Php[/LEFT]
 
 
[LEFT]//Ready the variables in our form for sending
   variables.userFName = f_nametxt.text;
   variables.userLName = l_nametxt.text;
   variables.userAddr = addr_txt.text;
   variables.userPhone = phone_txt.text;
   variables.userEmail = email_txt.text;
   variables.userClock = clock_txt.text;
   variables.userFullsvc = fullsvc_Cb.selected;
   variables.userWkd = wkd_Cb.selected;
   variables.userAsst = asst_Cb.selected
   variables.userMsg = msg_txt.text;
   variables.userwedDate = wedDate.text;[/LEFT]
 
 
[LEFT]//Send the data to PHP now
   varLoader.load(varSend);
   gotoAndPlay(10);
  }//Close else condtion for error handling[/LEFT]
 
[LEFT]}//Close validate and send function[/LEFT]

[FONT=Arial][SIZE=2][COLOR=#000000]

[LEFT][COLOR=blue]Php Code:[/COLOR][/LEFT]

[/COLOR][/SIZE][/FONT]


[left]<?php
//Create local variables from the flash actionscript posted variables[/left]
 
[left]$senderFirstName = $_POST['userFName'];
$senderLastName = $_POST['userLName'];
$senderAddress = $_POST['userAddr'];
$senderPhone = $_POST['userPhone'];
$senderEmail = $_POST['userEmail'];
$senderClock = $_POST['userClock'];
$senderFullsvc = $_POST['userFullsvc'];
$senderWkd = $_POST['userWkd'];
$senderAsst = $_POST['userAsst'];
$senderMessage = $_POST['userMsg'];
$senderWeddingDate = $_POST['userwedDate'];[/left]
 
 
[left]//Strip slashes on the Local-typed in variables for security and run any php based error check here[/left]
 
[left]$senderFirstName = stripslashes($senderFirstName);
$senderLastName = stripslashes($senderLastName);
$senderAddress = stripslashes($senderAddress);
$senderPhone = stripslashes($senderPhone);
$senderEmail = stripslashes($senderEmail);
$senderClock = stripslashes($senderClock);
$senderMessage = stripslashes($senderMessage);[/left]
 
 
[left]//IMPORTANT - Change these lines to fit your needs - IMPORTANT!!!!!!!!!!!!!!!!!![/left]
 
[left]$to = "[email protected]";
$from = "$senderEmail";
$subject = "";[/left]
 
 
[left]//Modify the message of the body however you like[/left]
 
[left]$message = "Results from the form:
First Name: $senderFirstName
Last Name: $senderLastName
Address: $senderAddress
Telephone: $senderPhone
Email: $senderEmail
Date of the event: $senderWeddingDate
Time of the event: $senderClock
Their message is below:
Comments: $senderMessage";[/left]
 
 
[left]//Build $headers Variable
$headers = "From: $from
";
$headers .= "Content-type: text
"; 
$to = "$to";[/left]
 
 
[left]//Send the email
 mail($to, $subject, $message, $headers);
 [/left]
 
 
[left]//Assemble the message that goes back to flash[/left]
 
[left]//The flash actionscript is looking for a return variable of "return_msg"[/left]
 
[left]$my_msg = "Thank you for your thinking of us!";[/left]
 
[left]//Print the data back to flash who is patiently waiting for it in the onCompleteHandler
print "return_msg=$my_msg";[/left]
 
[left]//Exit script
exit();
?>
[/left]

[LEFT]Thank you![/LEFT]