> > Tutorials > T1057

Send a form from Flash

Use PHP code to send email directly from Flash

flash form

Create the form:

  1. Create a new document and set the size to 400 x 300 (“Frame” > “Frame Size”) or other
  2. Set “Frame 1” to “Stop” (“Frame” > “Frame Delay” and check “Stop”, click OK)
  3. Create edit fields and labelsForm
  4. Double click each edit field to set its “Variable Name” and uncheck “HTML” for all fieldsedit fields
  5. Create a button, double click it and enter “Send” as the label.
  6. 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");


  7. Export Flash file with ‘File’ > ‘Export Flash SWF File’ command to the same folder where your HTML page is located.
  8. 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 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 = “”;

// use echo to display information after the user has submitted the form
echo”Thank you for your message”;

//list all fields
echo”<br>Name: $_GET[f_name]\n”;
echo”<br>Phone: $_GET[f_phone]\n”;
echo”<br>Email: $_GET[f_email]\n”;
echo”<br>Message: $_GET[f_text]\n”;


//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 .=”\n”;

$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);


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

get flash