Send a form from Flash
Use PHP code to send email directly from Flash
Create the form:
- Create a new document and set the size to 400 x 300 (“Frame” > “Frame Size”) or other
- Set “Frame 1” to “Stop” (“Frame” > “Frame Delay” and check “Stop”, click OK)
- Create edit fields and labels
- Double click each edit field to set its “Variable Name” and uncheck “HTML” for all fields
- Create a button, double click it and enter “Send” as the label.
- Choose “Action” > “OnClick”. Enter the following ActionScript code:
url = "mail.php?";url = url + "f_name=" + f_name;url = url + "&f_phone=" + f_phone;url = url + "&f_email=" + f_email;url = url + "&f_text=" + f_text;getURL(url,"_blank");
- Export Flash file with ‘File’ > ‘Export Flash SWF File’ command to the same folder where your HTML page is located.
- Choose “File” > “View HTML Code” and paste the code in your HTML page to embed Flash file
Create PHP file and name it mail.php. This file will send the form using your web server.
Paste the PHP code into your mail.php file. Replace firstname.lastname@example.org with your email address. You can customize the mail.php file to have your look and feel.
<HTML><BODY><!-- START EMAIL CODE --><?// the following code will send the email// consult your web hosting provider in case of any problems// you can copy & paste the code into your HTML page// copy all code between <!-- START EMAIL CODE --> and <!-- END EMAIL CODE -->// the form will work if published online// it will not work from your local disk
// put your email address here
// the form will be sent to this email
$to = “email@example.com”;
// use echo to display information after the user has submitted the form
echo”Thank you for your message”;
//list all fields
//send the email: $mailtxt is the content of the email
$mailtxt =”This text will appear at the top of the email”;
// use “\n” to add line breaks
$mailtxt .=” Name: $_GET[f_name]\n”;
$mailtxt .=” Phone: $_GET[f_phone]\n”;
$mailtxt .=” Email: $_GET[f_email]\n”;
$mailtxt .=” Message: \n$_GET[f_text]\n”;
$mailtxt .=”\nThis text will appear at the bottom of the email\n”;
$subject = “Put your subject here”;
$headers=”From: Your name <” + $to + “>\r\n”;
mail($to, $subject, $mailtxt, $headers);
<!– END EMAIL CODE –>
Upload all files on your web server: 1 Flash file (SWF), 2 Your web page, 3 mail.php file. Test the form if it works.
Consult your web hosting provider if sendmail if allowed for your account.
Download source project t1057.zip