useful tips and resources

AS2 Flash Contact Form

May 26th, 2008 · 87 Comments

Here is a working example of flash contact form with simple validations using ActionScript 2 and PHP mail function. This flash email form can also immediately response back to you if the email was sent successfully or failed. You can easily copy the contact form movie clip and paste it into an empty frame of any flash template.

flash contact form

You need to replace below red line with your email address in send_email.php file.

$receiver = “youremail@yourdomain.com”;

If your web server does not support PHP, you will need to use any other supported server side language for mail function instead of using send_email.php file.

UPDATES (24 June 2008): Adding Email Auto Response in send_email.php file

PHP:
  1. <?php
  2. $contact_name = $_POST[‘name’];
  3. $contact_email = $_POST[‘email’];
  4. $contact_subject = $_POST[’subject’];
  5. $contact_message = $_POST[‘message’];
  6.  
  7. if( $contact_name == true )
  8. {
  9. $sender = $contact_email;
  10. $receiver = “youremail@yourdomain.com”;
  11. $client_ip = $_SERVER[‘REMOTE_ADDR’];
  12.  
  13. $email_body = “Name: $contact_name \nEmail: $sender \nSubject: $contact_subject \nMessage: $contact_message \nIP: $client_ip \nFlash Contact Form provided by http://www.flashmo.com”;
  14. $email_body_auto_reply = “Hello $contact_name, \nThis is the auto reply message. Thank you. \nAdmin - http://www.flashmo.com”;
  15.  
  16. $extra = “From: $sender\r\n . “Reply-To: $sender \r\n . “X-Mailer: PHP/” . phpversion();
  17. $extra_auto_reply = “From: $receiver\r\n . “Reply-To: $receiver \r\n . “X-Mailer: PHP/” . phpversion();
  18.  
  19. mail( $sender, “Auto Reply - Re: $subject”, $email_body_auto_reply, $extra_auto_reply );    // auto reply mail to sender
  20.  
  21. if( mail( $receiver, “Flash Contact Form - $contact_subject”, $email_body, $extra ) )
  22. {
  23. echo “success=yes”;
  24. }
  25. else
  26. {
  27. echo “success=no”;
  28. }
  29. }
  30. ?>

UPDATES (22 July 2008): Error correction in send_email.php file

Please change $subject to $contact_subject in line number 15.

PHP:
  1. if( mail( $receiver, “Flash Contact Form - $contact_subject”, $email_body, $extra ) )

Feel free to drop a comment if you have any question or feedback.

Related Post: Flash Contact Form in ActionScript 3

Tags: Flash · PHP

87 responses so far ↓

  • 1 Dukes // May 29, 2008 at 10:02 pm

    I have tried this form but I get stuck at the “sending….” message. Could you please help?

  • 2 admin // May 29, 2008 at 10:12 pm

    Dukes, you need to run it on your web server which supports PHP.

  • 3 Dukes // May 29, 2008 at 10:33 pm

    I am trying to run it from my web server and its not working. I looked at the actions for sending and it has “send_email.php?flashmo=” in the loadvariables. Do I need to change that to send_email.php?

  • 4 Dukes // May 29, 2008 at 10:52 pm

    What I am trying to do is put this on an existing fla I am working on

  • 5 admin // May 30, 2008 at 9:58 am

    Dukes, Did you also upload send_email.php to your web server? Are you sure that your web server can run PHP?

    Please take a look at http://www.flashmo.com/preview/flashmo_104_circular which is integrated with this contact form. You will get an idea.

  • 6 Editing Flash Templates // May 30, 2008 at 1:14 pm

    […] order to make the contact form in contact page to send to your email, please read this post. You may write a comment to this post if you have any […]

  • 7 Dukes // May 30, 2008 at 8:44 pm

    I found my error. I had my html page in one folder and .swf and php file in another folder When I put them in the same folder everything works. Thanks for this form

  • 8 said // May 31, 2008 at 4:42 am

    Hi there I would like to say big thank you now is working fine .

    Many thanks
    Regard

  • 9 phpmailer // May 31, 2008 at 6:48 pm

    Hi there,

    im still having problems as featured above. It gets stuck on ’sending mail’. Ive even uploaded the default downloaded html, swf and php and just changed the email but still doesnt work.

    Im running a php site on a linux server. So i shouldnt see a problem

    Hope you can help

  • 10 phpmailer // May 31, 2008 at 6:50 pm

    found that when i press the ’send’ button twice, it then sends and i receive it.

    Can this be sorted to only press once?

  • 11 admin // May 31, 2008 at 7:18 pm

    phpmailer, please PHP mail function if it works or not.
    < ? mail("youremail@domain.com","Subject","Test","From Tester"); ?>

  • 12 said // Jun 2, 2008 at 2:22 am

    Hi Dukes i had the same Problem before so this flash form works fine what you need to do go and check with
    your hosting Package if that sport the PHP method or not if not you have to update it .
    Good luck

  • 13 Claudiu // Jun 3, 2008 at 12:30 am

    where is the download button?

  • 14 admin // Jun 3, 2008 at 10:55 am

    Download Source File link is located at the bottom of http://www.flashmo.com/preview/flashmo_102_contact_form

  • 15 Max // Jun 10, 2008 at 3:03 am

    THanks
    works PERFECTLY !!!!!
    all that i needed !!
    u rock !!

  • 16 arneberg // Jun 11, 2008 at 2:30 pm

    This may sound like a stupid question for the experienced - but we all have to start somewhere :-)) :

    Is there any way you can make this form work from a stand-alone Flash Player .exe-file that runs from a CD or does it only work when executed on the web?

  • 17 admin // Jun 11, 2008 at 3:09 pm

    arneberg, you may send the form variables to a mail client (e.g. Outlook) if it is on CD-ROM.

  • 18 thebastion // Jun 11, 2008 at 10:49 pm

    Hi there,

    where can I find the the line to amend

    $receiver = “youremail@yourdomain.com”;

    in the fla file. I have looked at the action script code on the mail form section but cannot seem to find it.

    I am using the floral template.

    Many thanks

    Stuart

  • 19 admin // Jun 12, 2008 at 9:35 am

    thebastion, please read it carefully again. That line is in send_email.php file, NOT the fla.

  • 20 Tan // Jun 16, 2008 at 9:32 pm

    Is it possible to change the actionscript to loadvariables from the php file located on another server, ie http://www.blahblah.com/send_email.php. How would i do this?

    Thanks

  • 21 Aaron // Jun 16, 2008 at 10:32 pm

    How do I edit the emailer in the flash websites…say for example file flashmo_079_classic.

  • 22 admin // Jun 16, 2008 at 10:44 pm

    Tan, it might be possible depending on security policies.

    Aaron, just remove all keyframes at the last frame (which is the contact page) inside “flashmo contents” movie clip. And copy “contact form” movie clip from flashmo_102_contact_form.fla and paste it into any layer of the last frame in your “flashmo contents” movie clip of flashmo_079_classic.fla file.

  • 23 Aaron // Jun 19, 2008 at 12:32 am

    thanks, I have yet to give it a dry run but I followed your intructs to the tee…Looks good. I also need help in the area…how do I add my own additional..say photos and other objects like a download button for pre-prepared forms and “send to a friend” links to the scripts and links to other websites. I have no idea where I post those. It’s away from all your help thus far…but could you help me…

  • 24 BGLdesign // Jun 19, 2008 at 12:41 am

    This is just what I was looking for… Min Thu is the man!

    Thanks,
    BGLdesign

  • 25 Arvie Morales // Jun 24, 2008 at 12:56 pm

    Hello!

    Thanks so much for this free email form. I am wondering though if it is possible to put an AUTO RESPONSE function in its PHP? I’d appreciate a quick reply. Thanks a lot and more power.

  • 26 admin // Jun 24, 2008 at 4:17 pm

    Arvie Morales,

    Yes, it is possible to put auto response in PHP file. I have updated my post above for it.

  • 27 Julie // Jun 27, 2008 at 3:17 am

    Hi there… I am a n00b at this stuff. I am using the flashmo_052 design and on the contact page I would like to add this contact form. I tried to import it into the library but it won’t let me. What is the best way to put this form into the .fla I am workin on.

    Thank you so much for your help. I did read through the comments but did not find my answer.

    Thanks so much

  • 28 Julie // Jun 28, 2008 at 12:23 am

    Hi again. I copied your contact form from the library of another flash template of yours and pasted it on the contact page of flashmo_052. I had to embed the text in the text fields in order for that to work. Here is my result..

    http://birdsongmarketing.com/2008.html view contact page. I have mt .php on my server in the same folder as the swf file. the emaill address I am using is for the server I have this on. Which is info@birdsongmarketing.com For some reason it acts like it sent because all the text cleared out plus it does not say sending or message sent. Not sure if I inserted the contact form correct or not into this .fla file.

    Any help would be most appreciated. :)

  • 29 Nikin // Jun 28, 2008 at 12:34 am

    You Really Rock Macha

  • 30 Aloonia // Jun 30, 2008 at 3:14 am

    My host can run php. But when I have tried this form I get stuck at the “sending….” message like Dukes. What should I do ????

    My site can run forum so it’s run Php contact form ?

  • 31 Aaron // Jul 1, 2008 at 9:22 pm

    if my server doesn’t support PHP, then what type of file extension do i use for the server side funtion posted at the top of this page

  • 32 AMani // Jul 3, 2008 at 3:30 am

    Hey my contact page seems to loop endlessly what could be the problem? Thanks in Advance.

  • 33 Arvie Morales // Jul 4, 2008 at 4:21 pm

    I have done everything but my message still stuck at “sending…” what’s wrong with this???

  • 34 admin // Jul 4, 2008 at 4:58 pm

    “sending…” is just because your web server does not support PHP or PHP mail function.

  • 35 Arvie Morales // Jul 5, 2008 at 10:18 am

    My server is yahoo. And according to them, they support PHP/PHP mail function.

  • 36 Leo // Jul 5, 2008 at 8:35 pm

    Hi,
    I copied parts of the script and tried to integrate it with another flashmo template ( 074).
    This is what i did, http://flash.pastebin.com/m101f379e
    But i think the loadVariables() part is causing the trouble, as i can’t send the email with the above script, although the original fla works just fine. Can you please help?

  • 37 admin // Jul 5, 2008 at 10:37 pm

    Leo, I have looked at your codes. You cannot do like that way. Please follow steps in http://www.webdesignmo.com/blog/2008/05/26/as2-flash-contact-form/#comment-346

  • 38 Kim // Jul 6, 2008 at 12:41 am

    Hi,

    I have inserted the contact form into my flash website but it is unclickable. The contact form is on a sub-page and it works fine if I just open that. But once I put the sub-page (with the contact form) into my main website, it becomes unclickable.

    Appreciate the help!

  • 39 sandeep kumar verma // Jul 7, 2008 at 2:54 pm

    hello sir i am trying it into my site

  • 40 Sergio // Jul 9, 2008 at 6:09 am

    Ups, the Flash template is nowhere.
    The link http://www.flashmo.com/download/flashmo_102_contact_form goes to a page with a link to the main page of flashmo.com

    Mmm

  • 41 Leo // Jul 10, 2008 at 9:03 pm

    Hello,
    I have got the contact form working. But the message_status field doesn’t seem to work. I always get “sending..” displayed.
    The email is being sent, so the php script must be echoing success=yes, I do not understand why flash doesn’t use that var?

  • 42 Bam // Jul 14, 2008 at 3:50 am

    Does the PHP file has to be in the “cgi-bin” folder of my server or in the same folder as my swf file?
    ————–
    I have it in both sections and can’t get pass “sending”.
    ——————
    thanks

  • 43 Bam // Jul 15, 2008 at 7:39 pm

    I’m glad to say that the form finally works. I’m using it in the above flash template. Now I can move-on. For those of you who are haunted by the “sending” phenomenon, (as I was) try recopying the flashmo files into your server and the flash action script files and keep all files (html, swf, and send_email.php) in the root folder of your server (plublic_html). That’s what i did and it worked. Good luck and thanks to the administrator.

  • 44 admin // Jul 15, 2008 at 9:11 pm

    Bam, I am glad to know that your form works finally.

  • 45 Despherado // Jul 17, 2008 at 4:40 am

    I’m so so English.Please Turkish ??

  • 46 Aaron // Jul 18, 2008 at 11:48 pm

    can you tell me how I can change the auto response message in the original AS2 Contact form

  • 47 edson principe // Jul 19, 2008 at 3:31 am

    know you if hotmail support php ? Contact Form Flash does not work. The 4 files are in the same directory.I already changed ($receiver = “info@flashmo.com”;) in send_email.php

  • 48 Aaron // Jul 20, 2008 at 2:44 pm

    ANYONE! can you tell me how I can change the auto response message in the original AS2 Contact form. send an email to arebegees@gmail.com

  • 49 Burntproduce // Jul 21, 2008 at 6:16 pm

    I’ve noticed in both versions of the script (sans auto-reply and auto-reply) you forgot to add “contact_” to the $subject variable when setting up the mail function. These need to be changed from $subject to $contact_subject or else the subject on the form email and auto reply wont display the subject properly.

    Thanks a million for this script. After a week of sheer frustration and 3 other scripts this is the first one i’ve used that seems to work properly!

  • 50 admin // Jul 22, 2008 at 10:37 am

    Burntproduce, Thank you for pointing me out about the mistake - $contact_subject variable. I have corrected above.

    You are right that $subject variable will not work if the PHP variable register_global = off in PHP.ini settings.

  • 51 Nesha // Jul 23, 2008 at 4:37 pm

    Hi
    Can you please help me figure out how this wud work? i did follow up all the instructions
    changed the recive email address to mine in send php

    when i upload the form to the server the form looks fine but when i fill in the form and click send it get stuck on “sending…” nothing happens after that. ” i am using my yahoo account address as the reciever email.

    could you please guide me and explain to me how to it this form working.

    hope to hear from you soon thnx

  • 52 Nesha // Jul 23, 2008 at 5:02 pm

    Hi Again,

    just wanna to tel you i do get both messages to my emails

    but when i submit the form it dosent say the message is been submit it just stays freezed on sending… and when i click few more times on the send button the sending… message dissapears but the form dosent clear out. it still stays freezed with the information typed.

    could you please help me out with this. thnx

  • 53 timmaeee // Jul 24, 2008 at 4:06 am

    hey,

    just curious… i’m currently trying to edit flash_079_classic template, and i can’t seem to edit the title, slogan, or copyright info. what do i do?

    thanks, i’d appreciate a sorta fast reply :)

    x

  • 54 wes // Jul 29, 2008 at 2:21 am

    hi,

    I’ve got a quick question. The form is working fine for me, but I’d like to change one thing. The text that appears under the form telling the user to “please provide a valid email” or “sending” is always red. This color really clashes with the color scheme on my website. How can I change it to white?

  • 55 Wojtas // Jul 30, 2008 at 12:04 am

    Hi,I’ve a problem.When I click the SEND button I get an error “Your message couldn’t be send.Please try again.” Please help!!!

  • 56 Juna // Aug 1, 2008 at 9:13 am

    Hi!

    First -Thanks for the form!

    But I have the same problem as Nesha - form does not resets after I press “send” button.

    After button is pressed again - the message dissapers But all info typed - stays in the form. I dont think it is the server. I do get emails from the form. (auto respond to!)

    What could it be - anyone?

  • 57 fernanda // Aug 7, 2008 at 8:17 am

    Please, how to make it work on flashmo_092_restaurant template?

  • 58 Jhay // Aug 13, 2008 at 12:08 pm

    how can i get it to work on flashmo_081_design help please.

  • 59 Flash Contact Form in ActionScript 3 // Aug 14, 2008 at 9:05 am

    […] contact form is simply made in Adobe Flash CS3 ActionScript 3. Email validation is better than previous version in ActionScript 2. It sends the form field variables to PHP and loads the response variables back to Flash using […]

  • 60 Lance // Aug 20, 2008 at 10:53 pm

    I cant download it. The “Download Source” link does nothing. Judging by other posts here, I’m not the first with this problem

  • 61 Lance // Aug 20, 2008 at 10:54 pm

    Can someone re-host the zip file for this? =)

  • 62 Ugur // Aug 29, 2008 at 4:26 pm

    Hi, Admin.
    I edited template 118 fashion gallery and upload our host but I’ve been realized sadly to our host has not .php support.
    Is there any way to solve this problem by AS, JS etc. ?

  • 63 michael // Sep 3, 2008 at 7:35 am

    hi, I cant get work this form, I uploaded all files, and change receiver for my mail adress but I cant receive the form in my mailbox, im using hotmail, but its not working, pd. Im using flashfomr for as2. please help.

  • 64 michael // Sep 4, 2008 at 7:45 am

    gr8t all done!! thx

  • 65 Corey // Sep 6, 2008 at 1:25 pm

    Greetings,
    I’m not sure why admins stop giving assistance but it appears many of us are still having trouble. I accomplished everything I’ve wanted so far except putting this contact form on my existing fla. The fla is from flashmo and has an example set up but not ready to work.
    So I download this, copy everything from the Library, Movie Explorer and Actions over to my fla or even a blank fla but NOTHING works.

    I’ve uploaded this html, swf and email_php and it sends the e-mail fine. But I just CANNOT get it to transfer to my fla. I even created a new one and and made an exact copy of everything but still nothing.
    Does anyone know if renaming the swfs and etc could effect it? I wouldn’t think so as long as the codes all pointed to the right files but I am stumped. ANY help what so ever would be appreciated. I’ve given assistance to others on this site, just hoping someone else can do the same…
    Thanks

  • 66 Saber // Sep 12, 2008 at 8:17 pm

    Is there any way you can make this form work from a stand-alone Flash Player .exe-file that runs from a CD or does it only work when executed on the web?

    I am quite new at this, would appreciate some assistance.

    Many thanks

  • 67 admin // Sep 13, 2008 at 10:44 am

    Corey, I do not stop giving assistance. It is just that I do not get enough time to support everyone though I try to support as much as I can. I am really sorry about that.

    Saber, I think it is possible by sending form fields data to Outlook or another email client for email.

  • 68 Ugur // Sep 14, 2008 at 2:24 pm

    hi admin!

    will you answer my question up there?

  • 69 curious // Sep 14, 2008 at 5:14 pm

    Hi admin,
    bigups for the wonderful works your are doing. I am trying to insert or import an intro template into a website template, all in flash , but this has not been easy. need help please

  • 70 admin // Sep 14, 2008 at 6:13 pm

    Ugur, there is no way to send email by AS or JS only. You need to have server-side mail processing scripts such as PHP, Perl, CGI, or ASP.

  • 71 Saber // Sep 14, 2008 at 11:45 pm

    Hello Admin,

    I would appreciate it if you assist me with the script when you say sending form details to Outlook since I am very new to flash an am learning my way round.

    Appreciate your time.

    Many thanks

  • 72 jolz // Sep 15, 2008 at 2:47 am

    i’m having the same problem as the one reported above. I just see ’sending..’ and nothing else happens. i changed the html page housing my swf to *.php extension. What is the possible problem?

  • 73 PHil // Sep 15, 2008 at 4:10 am

    I am needing help with a contact page submit button directly to my email address? I am not understanding the flash php dual script. I have surfed around and found that the only thing is to put “on (release) ; { get to url(myemail) } but it does not work. I know it is simple however I am extremely lost on this piece. Please help

  • 74 Roco bach // Sep 15, 2008 at 5:02 am

    Hi there – Any Help would be appreciated
    I can’t get this contact form to work at all. It just gets stuck on “sending…” It does not send at all
    It says “sending…” and does nothing then hit Send again and the form just clears.
    I have changed receiver to my email address
    I’ve contacted my ISP and they say that they support php however the php file must be within a folder named cgi-bin- I’ve set permissions for “send_email.php” to 755 even 777 and tried placing it inside and outside the cgi-bin and nothing works. I also believe that the server is a linux server.
    On reading the forum I see users gets results when all three files html,swf & send_email.php are within the same folder. This I’ve tried and again no luck however my ISP says that all .PHP must not be on the web space server only within the cgi-bin.
    I’ve have even tried changing the path loadVariables(”send_email.php?flashmo=” + random(1000), this, “POST”); to loadVariables(”http://ccgi.username.plus.com/cgi-bin/send_email.php?flashmo=” + random(1000), this, “POST”);
    Done all I can and no luck at all. Please help as I’m getting annoyed and about to give up.
    Thank you

  • 75 admin // Sep 15, 2008 at 8:19 am

    Hello jolz and Roco bach,

    Before you are making this flash form works, you need to make sure your web server supports PHP mail function by testing a simple mail script that sends email to your inbox. There are a lot of samples, just type “php mail” in Google and search. :)

  • 76 admin // Sep 15, 2008 at 8:20 am

    Hi PHil, you cannot send the flash form data directly into your email. You need to have a server-side script such as PHP, ASP, or JSP for mail processing.

  • 77 jolz // Sep 15, 2008 at 3:43 pm

    i have designed other sites running php on my laptop. I always test them and they always run. I will try to upload it online to my webhosts server and see if it runs just assuming d problem is with the php mail function

  • 78 Roco bach // Sep 16, 2008 at 7:12 am

    Run php mail test within cgi-bin on my server and all is working. It appears that the form has issues because the .php file is located within this cgi-bin folder even though persmissions are set to 755.

  • 79 Roco bach // Sep 16, 2008 at 7:17 am

    Is there anything that needs to be edited either within the action script in flash or .php file to make this form work being that the .php file is not located within the same folder as the html, swf. on our servers?

    Thank you for your support

  • 80 admin // Sep 16, 2008 at 7:49 am

    jolz, some hosting does not allow php mail function. You will need to do extra mail setup using SMTP and phpMailer for that case.

    Roco bach, I am not sure about CGI-BIN because I do not know anything about it. Sorry :D

  • 81 Roco bach // Sep 16, 2008 at 11:16 pm

    ADMIN – Thank you for your time and support which is gratefully appreciated.
    BINGO! – I’ve managed to have this form working. It seems I had the same problem as user “BAM” being that our servers include a cgi-bin for .php files. I contacted my ISP and explained that all 3 files .html, .swf & .php must be in the root folder. They made some adjustment which was beyond my control - Whalla!
    Question to “ADMIN” - My ISP explained to me after viewing the “send_email .php” script that this script is basic and open to abuse by hackers. By having such script open would jeopardise my account if subject to abuse. Could this script be updated so that it Hacker Proof?
    I’m gutted – SERIOUSLY Gutted, I adore this Form, The best I’ve come across on the net, I’ve tried to get this form working for over a week and finally I’ve got it working, I’m told I run a 99.9% risk of being hacked. I’m so Hacked off.
    I know nothing about PHP scripting. I wouldn’t know where to start to prevent being hacked.
    Any advice or an updated hacked proof script would be much appreciated.
    Again – Thank you for your support.

  • 82 Mark // Sep 17, 2008 at 2:05 am

    I’ve added this form onto my website but it only works if I change the html file to my index.html page.

    I want to load this swf file into another swf file but doesn’t get passed sending… when I try it that way.

    All of the files are in my root folder so the url’s should be fine.

    What could be causing this problem?

  • 83 Julie // Sep 24, 2008 at 3:07 am

    Hi there. Is there any way that I can add an additional email address in the php file. so the email will go to two different emails???

    And curious if there was any way..when it says message sent, can that stay on the form for alittle longer than it does???

    thank you
    Julie

  • 84 admin // Sep 24, 2008 at 8:02 am

    Julie,

    Yes, you can do that in PHP file the following line…

    $receiver = “youremail@yourdomain.com, secondmail@yourdomain.com”;

    You can also make it a bit longer by increasing the number of frames.

  • 85 Carlos B // Sep 26, 2008 at 3:51 am

    Great stuff fella thanks!

    Just a quick question… how hard would it be to send an attachment stored on the server with the email? i’ve currently got a form that uploads an image to the server and takes some user input, but i want to add the image as an attachment… any ideas?

    Cheers
    C

  • 86 leigh // Oct 2, 2008 at 7:37 pm

    I did a site for a client and he is now asking if he could recieve the email from the contact form in html format.
    How do i do that. and is there a way that i can let the form send a copy of the message to the sender?
    thanks
    Leigh

  • 87 dimitris // Oct 3, 2008 at 10:26 pm

    my contact doesnt work….it say that it send it by the e mail doesnt come to my email…my server support php

Leave a Comment