Skip to Content

How to make a Flash contact form

Author: Bill Trikojus

On almost every website you will find a contact page.  This tutorial will show you how to create a contact form that visitors to your flash website can use to send you an email.

1

Part one

bulletLaunch video file

1

Part two

bulletLaunch video file

1

Part three

bulletLaunch video file

   

Download the finished source files here

bulletBack


Share

Like this? Click a link below to share it...


Subscribe and Download

Subscribe to the Swinburne Faculty of Design Podcasts

Comments

2008-07-08: Justin said:
Hi there, i have a question with this tutorial. I found it very good, and my files work before i upload them (obviously with the exception of the email going through) once they are uploaded though, my sent dynamic text box on the sent page actually displays the message i have typed in the email form...not the php message. But as i said it display's the php one before i upload it. Any ideas? is it something to do with my host?

2008-07-08: Justin said:
No worries, i fixed the problem. It was some scripting error in my php, it obviously only showed up online.

Thanks for the good tutorial

2008-08-05: reico said:
works

2008-09-17: Alessandro Campos said:
Very good!! Congratulations, and thank you.

2008-09-27: danish said:
hey please tell me how i can make 3d website

2008-11-01: Stelios said:
Congratulations and thank you! With your tutorial I understand how the fla files work with the php. And I would like to thank you one more time for the links.

2008-11-02: Stelios said:
Can you help me in a problem that I have with the form? I can't send Greek fonts. Could you please tell me how?


2008-11-08: lisa said:
Thank you for the tutorial!
however, I do have a problem:
my server supports PHP5
will my form work?
The thing is when I hit 'send" I get an error message "Error sending message".
Could you help?
Thanks.

2008-11-08: Bill Trikojus said:
It might be PHP5 causing the problem or it could be something else to do with the server config. Might need to contact your web host

cheers

2008-11-16: Alain said:
AMAZING tutorial! Only problem I have is that I am not using the form on the main timeline and in addition, it is in a swf that is contained in the main movie, so its not the root. Because of this, its not loading the php. Any tips?

2008-11-16: Alain said:
I'm not sure I explained it well in my last comment: if this form is in a swf that is a child of the main movie, when you click submit it results in "load didnt work". But if its played by itself (no called by a parent swf), it works fine. Do you have a solution?

2008-12-11: danish said:
good tutorials

2008-12-28: Ryan said:
I have the same problem as Alain. After uploading to my site I tested it and when pressing send I got "load didnt work". Is it because I need to change the smtp to something else like pop?

2008-12-28: Ryan said:
Nevermind I fixed it and it works. Great tutorial.

Alain be sure to double check your actionscript. My problem was that I had the contact.php in a seperate folder called mail but did not state so in the actionscript.

2009-01-27: j4ke said:
How would I handle a large amount of string(3-5MB) being sent to PHP from Flash to be saved as a text file..using sendandload

Thanks

2009-02-13: Mark said:
I am still getting the 'Error sending message' message.
I even tried just uploading the source files (after changing "you@your.com" to my address). I am using Yahoo web hosting. Could that be the problem?

2009-02-17: Narada Dilshan said:
Hello sir,

Thank you for great work.I test it.I change htmlMimeMail.php smtp settings in Defaults for smtp sending according gmail smtp settings.

I got error load didn't work.
Explain and how to correct

2009-02-17: Bill said:
Evey server is different. Please contact your host.

2009-02-17: Narada Dilshan said:
Thank you for your answer.I'm new to this subject.I'm testing much more things with free providers.At last find free domain register with dns.Free web hosting with out banner ads also.
My hosting provider doesn't support SMTP.But I want to try gmail SMTP.Early I said that I have change htmlMimeMail.php smtp settings according gmail smtp settings.Can you tell me can I use gmail smtp with htmlMinemail.My hosting provider support php 4,5 and 6 also.

2009-02-23: Narada said:
http://www.mediafire.com/?lyqnymtt0jt

download above file I have explain all with my flash & php codes

2009-03-08: MAN Thank You said:
Thank You Sooo much for your tutorials and source files.

This is one of the best sites I've come acorss for learning flash.

Great Work and Very well explained.

2009-04-10: Jay Dea said:
Just one question , i got the message that the mail was sent just fine, but I do not receive any of the mails.
I only changed the mail adress in contact.php and removed the 'SMTP' behind the mail adress. tried different hosting providers. What could be the problem?

2009-05-13: Johannes said:
Nice contact form!

My only problem is that I'm a Dane. We people in Denmark have some funny letters like æ,ø and å. Can anybody tell me how I implement these characters?

2009-05-15: fatih said:
its work with smtp
many thanks


2009-05-30: Abhishek said:
This video is so simple and the best to know the php form in flash
but you should give the video download link of the tutorial coz, this will much time if the net connection is slower.


thanks

2009-07-23: Irakli said:
Hi, I have the same problem as shown in the first comment. All I am seeing after pressing send is the actual message that I have typed. Can anyone tell me how to correct this?

thanks in advance

2009-07-28: jenni said:
Hi Thank you for this tutorial, I am having a problem, when I add the contact to my site, when I type in an email address it says this is not a valid email, other wise it seems to be working my server support PHP, thank you in advance

2009-10-16: Michael Wentworth-Bell said:
great tutorial! I was wondering if the Swinburne OPAX space will support .php?
I have uploaded my contact form and seem to be getting an error. Tried checking through the code, but was thinking it might just be that the OPAX server doesn't support php?

2009-10-16: Bill Trikojus said:
Hi Michael,

Yes the opax server supports PHP. You may need to change the email is sent via. Can't remember the exact code but it will be something like

$result=$mail->send(array("$email"),'smtp');

The second parameter is the method. If it already has smtp, remove it and the comma, otherwise add it. Failing that, try sending to a different email address.

All the best
Bill

2010-04-25: Rick said:
Fantastic tutorial, and this is the ONLY contact form that I found to work perfectly and I could customize it as needed.

It works like a charm in a stand-alone form, and also embedded into an html page.

BUT here is the problem:
when I embed the form into the Flash website I created it for (embedded into a form_mc), everything still works EXCEPT the "Send" (submit_btn) will not send the message. There are NO errors (i.e. "loading failed"), nothing happens at all if the "Send" button is pressed.
The button does function however, because if it is pressed with either the "Name", "Email" or "Message" fields empty, it will bring up the respective error messages.

I've been through the code almost letter for letter, even tried adding
this._lockroot = true;
but can't figure out what I'm missing, and why the form won't send from inside the Flash website.

Any kind of help or suggestions would be greatly appreciated.

Thanks.

2010-04-26: Bill Trikojus said:
You probably just need to fix the paths to the form elements. Check this site and others for a basic intro to paths in flash tutorial.

cheers

2010-05-31: Alexandru said:
Hello Bill, can you please help me?
When i send the email, it says "Message sent.. " etc.
But nothing comes to my email. I dont't receive the email that i've just sent.
I only modifyed the email adress in contact.php and deleted the 'smtp' because i use GMAIL and it has allready smtp. I tried with 'smtp' too.

I don't receive anything.
What can i do?


2010-05-31: Bill Trikojus said:
You need to speak to the company that hosts your website as every server is different. SMTP has nothing to do with the 'receiver' so ask your webhost about that too.

cheers

2010-05-31: Alexandru said:
I don't have a web host, i made a server on my PC, i have WAMP with APACHE server installed and it supports PHP. Should it be because i didn't use a web host?

2010-05-31: Bill Trikojus said:
Not sure. see if this helps

http://www.wampserver.com/phorum/read.php?2,31302,31324

2010-06-14: Msg said:
thank you so musch
I like this

2010-08-15: ben said:
Hi, i have seen the tutorial on this and very much like it. but i would like to know if i like to insert in a combobox to it, how should the actionscript be like? Thanks in advanced.

2010-11-25: tb5 said:
this was a great tutorial...

i am however having the same issue as the first poster...
message_txt seems to be getting mixed up with theMessage_txt

he seemed to have fixed it i dont see the error.

thanks for this once again... perfect

2010-11-26: tb5 said:
nvm... found the error...

apparently the location of htmlmimemail was wrong...

fixed it up and things are working...

thanks again!

2010-12-08: Robert said:
Thank you so much for the tutorial.
Like everyone else here I have one small issue.

Every message I send I get a "message was sent" notification.
However only a few were actually received.

The only difference is the email address in the form that changes.

I deleted the 'smpt' out of the contact.php. Could this be the issue why it only sends with select email addresses?



2010-12-08: Bill Trikojus said:
no the smtp should just depend on the config of the mail server.

Have you checked the junk mail folder of the addresses that you think didn't work? I've noticed hotmail has a habit of flagging email send via scripts like this as spam.

2011-03-16: Sergie said:
part2 does not open...

2011-03-16: Sergie said:
Thanks for the tutorial,
i have done it and checked one time, but i have a problem.. in all the cases error writes invalid email. cant understand what`s wrong please help, i have checked all twice, but found nothing

2011-03-16: Sergie said:
I have solved this problem . don't know what was the problem i have, had just copied AS from source contact form and everything started work properly. i saw that people above (Alain and Ryan) had the same problem that i have now. load didn`t work, i have 3 folders with the same files. i did that for translation(i have 3 languages... the same folders but with different names(for example)(eng, rus, ned))..... what i need to write in AS to show that they are in other folders ??

2011-03-17: serz said:
Hi, When i put this form into the main directory, all works properly, but i have structure of my website like this: i have 2(eng, rus folders) main directories which are language folders, with the same folders and files into them. inside i have 2 folders flash(main files+contact form) and image folder with 1 pic inside...... i know badly now php and AS2 to solve this problem by myself.... If someone can help me, please help to solve this problem.

2011-03-17: serz said:
structure looks like this....

public_html/eng/flash(here is the main files of flash and contact form)

and another path is the same but (est) instead of eng

2011-03-17: serz said:
sorry, RUS instead of eng

2011-03-17: Bill Trikojus said:
I assume you are wanting to know the path to the php scripts from the flash movie? You didn't say where the php files were, but if they are in the public_html directory, and your flash file is in public_html/eng/flash, then the path would be

../../your.php

2011-03-17: serz said:
Thanks for your prompt answer .No, you didnot understand i know the contact.php path and that it must be with my.swf file , problem is different as i wrote above when i put all flash and contact form files into the directory /eng/flash appears error message "load didnt work", but at the same time if i will put all these files to public folder and delete all folders it will work properly , it seems that i need to fill in something into AS or php file ..... but where i need to do that i dont know://

2011-03-17: serz said:
i have tried to change this line in AS
contactVars.sendAndLoad('eng/flash/contact.php',contactVars,'POST');

but didnt help....

2011-03-17: serz said:
i did it )))
correct path was contactVars.sendAndLoad('flash/contact.php',contactVars,'POST');

Thanks for the tutorial, best contact form!!!

2011-04-08: Donald Orr said:
I have created this script but have added some text boxes. I have one for phone, a customer referral, and also referral's phone number.$phone=$_POST['thePhone'];
$referral=$_POST['theReferral'];
$rphone=$_POST['theRphone'];
how do I get these into the body of my email.

2011-04-27: heavy said:
hi;

form & file upload sample please! (with AS2)

2011-05-30: Alan said:
Bill, We don't use php at the moment and this would be it's only function. I gather that when you say the server should support php, you mean that php must be installed. Can you recommend a version for a win2008 server?

2011-05-30: Bill Trikojus said:
Most windows servers should have php installed as well. You could also translate the php into asp and use that if it is available. Exact same code is used inside Flash.

http://www.codefixer.com/tutorials/sample_form_email_script.asp

2011-05-30: brm said:
the first tutorial that rly wrk, nice and clearly explained...

many thanks mate...

2011-06-02: maggie said:
i have a little problem ..my sent dynamic text box on the sent page displays the message i have typed in the email form,not the php message. i cant figure it out what is wrong? plus i dont receive any email.. help pls

2011-06-02: Alan said:
Bill, further to my previous question, I need to test the email capability on my development system running XP. We don't use IIS, we use ColdFusion and have the developer version installed. How do I install php? I understand you have to point it to a webserver, so will it recognise CF?

2011-06-02: Bill Trikojus said:
Yes I'm sure CF will also do the job just fine.

2011-06-03: Alan said:
Following along with your excellent video tute, you exepct the email to contain html code but mine does not. So, how does that change the code in contact.php?

2011-06-03: Maggie said:
As i said before i've been having problem with thw contact form.
I changeg my php and when i run it in my computer it works.. well apart from the fact that i get message sent thanks";}?> which is part of the code in php file,
and when i upload it it says sending and instead of saying msg sent it says the same thing i wrote on the message field of the contact form.

Please can someone help me?? i dont i dont understand wht im doing wrong did th etutorial again and have the same error. thx

2011-06-06: Bill Trikojus said:
@ Alan have a look at the mail class documentation. Pretty sure you just use setText() instead of setHtml(). Something like that anyway.

@ Maggie there are so many things it could possibly be. In your actionscript code, try adding some more test code that outputs errors when they occur. For example, in the onLoad code you probably have something like

if(ok)
//message from php gets output
}


add an else statement to this


if(ok)
//message from php gets output
}else{
//output an error to your text box
}


If that doesn't show any problems, you may need to listen for specific error events.

All the best

2011-06-28: Joseph said:
No mater what I try, when I press send, I get the error sending message error. I use godaddy as my hosting.

2011-07-18: clara said:
Hello,

Thank you for the wonderful and thorough explanations for this form. I was wondering how I would go about making it possible to insert accents à éè etc... as they are not presently working.

Thanks in advance !
clara

2012-04-04: umair said:
my form is not working. I am making it in a movie clip. Does it effect the form??

Post a comment

Garbage posts and SPAM will be deleted.

* Name:
* Email: (will not be made public)
* Comment:
* Reply Notification: