How to Mail flash form with actionscript

January 7, 2010

Actionscript 3.0 Tutorial

Use PHP code to send email directly from Flash

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 labels
  4. Double click each edit field to set its “Variable Name” and uncheck “HTML” for all 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 youremail@yourdomain.com 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 = "youremail@yourdomain.com";

// 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";

echo"<br>\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);

?>
<!-- END EMAIL CODE -->
</BODY>
</HTML>

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 here

, , , ,

18 Responses to “How to Mail flash form with actionscript”

  1. joenbaldwin Says:

    The writer of http://www.flashconf.com has written a superior article. I got your point and there is nothing to argue about. It is like the following universal truth that you can not disagree with: When working a support phone the phone will always ring when you close Netscape and try to get some real work done. I will be back.

  2. barrierefreies webdesign Says:

    I studied the html tutorial and I really learned a lot. I think my next homepage will be a lot better than my first one.

  3. tommy Says:

    great help. Thanks

  4. The writer Says:

    Very well I could hardly agree more with what you just have said

  5. billy Says:

    Awesome lookingsite who did the design?

  6. Kris Says:

    Is it possible that a user can draw in a field, and then have the drawing sent along?

  7. Walter Says:

    Immer wieder taucht die Frage auf, wie sich SSI in WordPress einbinden läßt ohne sich großartig z.B. in die PHP-Programmierung einarbeiten zu müssen

  8. sam1 Says:

    nice one, thnks

  9. Jules Duffee Says:

    Hm ,.. Yes the best way is to just play like my friend Sol Dasso he just play games and enjoy his life.

  10. Dillon Veino Says:

    Put your deliver the results in an over the internet portfolio. I am confident there can be a CPU there. Net layout is about far more than very good design and style. It is actually about user friendliness and functionality. If someone is going to hire you, they will want to work with the internet web site, not see it.

  11. guitar ultimate Says:

    Nice one, cheers for the tip

  12. Leah Says:

    Reader’s next year will be better knowing this!

  13. Andrey Says:

    Hello,

    I have a problem with this…. I did everything like it says but when I receive email it says Name:undefined.
    Thank you for your message
    Name: undefined
    Email: undefined
    Phone: undefined
    Address: undefined
    City: undefined
    Zip: undefined
    Type of service needed:
    Frequency:
    Approx square footage:
    Type of room:
    Number of bedroom:
    Number of Baths:
    People living in your house:
    Number of pets:
    Preferred Quote Method:
    Message: undefined

    Would you please tell me what I’m doing wrong. Thanks.

  14. Jonas Lehrian Says:

    First off good site. Im not sure if it has been addressed, nevertheless when utilizing Chrome I can never get the entire weblog to load with out refreshing alot of occasions. Could just be my laptop computer. Enjoy!

  15. Marisela Ladell Says:

    Write this up into an ebook or something… this stuff is Gold!

Trackbacks/Pingbacks

  1. How to Mail flash form with actionscript | Flash tutorial | Flash … | Coder Online - January 7, 2010

    [...] Read the original: How to Mail flash form with actionscript | Flash tutorial | Flash … [...]

  2. Tha Trackback » Blog Archive » How to Mail flash form with actionscript | Flash tutorial | Flash … - January 9, 2010

    [...] Found this interesting post today, here is a quick excerpt of it: Tagged as: ActionScript, flash form with actionscript, How to Mail flash form, Mail form Flash, Send a form from Flash Leave a comment. Comments (0) Trackbacks (1) ( subscribe to comments on this post ) … Read the rest of this great post Here [...]

  3. how to Launch email from Flash animation | Flash tutorial | Flash video | Flash actionscript | flash animation |macromedia flash | flash menu | flashconf.com - January 9, 2010

    [...] See also:  Send a form with PHP [...]

Leave a Reply