Simple flash AS3 contact form with field validation
This is an example of how AS3 aint all that bad.
I simply converted an already existing AS2 contact form to AS3.
Looking at the fla you will see that not much has changed.
The only major difference is how you setup sending your vars to the php script.
An example can be seen here.
I have also attached a working fla with php script.
![]()
Need a custom contact form built?
Feel free to email me
Tags: AS2-AS3 conversion, AS3 flash contact form, convert AS2 to AS3, CS3 contact form, email form AS3, email form flash AS3, flash AS3 contact form
July 18th, 2008 at 6:55 am
um… i appreciate the form and flash files and php, but where’s the AS 3.0 to make this form work?
July 18th, 2008 at 7:08 am
nevermind… found it nested in the movieclip – thought it would be on the main timeline.
thanks!
August 2nd, 2008 at 1:42 am
Hi, thanks for offering the code. Having trouble though.
I’ve uploaded it to my server which has I’ve tested and is confugured for php, i’ve placed the files in the same folder on the FTP.
I’ve done nothing to the code bar enter my email address & when I submit the form it hangs on the “Submitting Form Please Wait” message, and no email is received.
Any ideas? Cheers. Mark
August 2nd, 2008 at 10:15 am
Point your browser to the php script and see if any errors are ouptut.
August 2nd, 2008 at 10:54 am
When ran in the browser it says “Email address not found”. If I haven’t posted back by the time you read this I’m still struggling!
August 2nd, 2008 at 11:03 am
Hmmm… well the script is recognized and is doing what it is upposed to.
Can you email me the link to where you have it setup?
August 2nd, 2008 at 11:27 am
Is that windows hosting your on?
It maybe that your php ini default email address does not reflect the email address you trying to use.
I do a lot of php work on windows server system and generally find that php can be somtimes a bit funny with mail().
What would normally work on a linux based server would not always work on a windows based server with php installed.
Can you confirm what server your hosted on.
August 2nd, 2008 at 11:31 am
Testing you page i get 404 on the php script.
Have you definetly uploaded swf and php script to same dir?
August 2nd, 2008 at 11:41 am
Yep, I’m hosted on a windows server with easyspace
August 2nd, 2008 at 11:42 am
And yeah, swf & php are both in my /Images folder – is it worth moving tehm both up a folder to the same page as the aspx?
August 2nd, 2008 at 11:44 am
Ha – just moved them up a level & it works. Unbelievable
August 2nd, 2008 at 11:52 am
Thanks for the form & for looking into the prob for me Paul, muh appreciated – all working & happy now!
August 2nd, 2008 at 11:52 am
ok so your pulling your swf from a sub-directory and displaying it in a page on your main directory. Flash will still think it’s in the sub-directory even though it’s being viewed in a page on your main directory(root).
Usually what i do with my swf’s is to have them all in my root directory and then there assets in sub directories of the main.
example:
httdocs/root/
-index.html
-someswf1.swf
-someswf2.swf
-images/
-images/image1.jpg
-images/image2.jpg
-xml/
-xml/somexml.xml
-php/
-php/some.php
As you can see i store my swf assets and site assets in sub-directories of the root folder.
Put your swf,php in the same directory of the page it’s embedded in and try again.
most probably that will be the issue.
if you dont want to go that route then you can jusat direct link to the php script in the swf.
Open the fla and go into the form mc. Select layer1 and open the as panel.on line 3 you will see:
var req:URLRequest = new URLRequest(“contact.php”);
Replace the “contact.php” with the full url to the php script
var req:URLRequest = new URLRequest(“http://www.somedomain.com/php/contact.php”);
let me know if you have any problems
August 2nd, 2008 at 11:58 am
cool, all sorted – but i tell ya, you’ll get some people with the same prob as me landing on that post you just did above – cos I found nothing else like it in my searches! thanks again. mark
August 19th, 2008 at 2:16 am
any where i can test my form out? and see if it works?
Or do i have to be on a server
cause hwen eve ri test it out, it never works =( says Error
August 19th, 2008 at 7:00 am
Does your server support php?
August 21st, 2008 at 8:03 pm
Thanks for the script and the files. They are a big help. I was able to get the contact form set up and I can get it to send an email, but it looks like none of the items you fill out are posting to the php script. Would this be a problem in the AS or in the PHP? ANy help would be appreciated.
August 21st, 2008 at 8:31 pm
Have you made any modifications to the files?
It should work striaght out the box as long as your server supports php and you have also set a valid email adress in the php script.
August 22nd, 2008 at 4:57 pm
I did modify the code slightly to include a company name field and on submit to gotoAndStop on a custom second frame that displays a thank you message. It’s just strange that some of the information is coming through but nothing that they fill in.
August 22nd, 2008 at 5:54 pm
i can tell you that the files are working correctly. You must have deleted or moved something you shouldnt have. Why create a second frame for a thank you as well? I already have that in place.
September 16th, 2008 at 3:34 pm
Hello Paul,
Thanks for this nice as3 contact form. After tweaking some of the graphics I just copied it onto my simpel flash portfolio I am building and it is working 100%
Thanks alot.
September 22nd, 2008 at 11:18 pm
hello paul,
thank you for the very helpful posts and info.
i have a question about this contact form, and the strange behavior i’m seeing, and perhaps its related to what this guy above was seeing a few weeks ago…
the short of it is, the emails received only display the very first line entered into the “txMessage” input field…
the only way i’ve found to get the entire message to show up is to type continuously on one line without using any carriage returns…
thanks a million in advance, this contact form has saved me several migraines and lots of time!
r
i
September 23rd, 2008 at 6:48 am
Make sure the txMessage field has multiline set.
September 25th, 2008 at 2:30 pm
How much would you charge to customize the AS3 contact form to mimic the one on this site:
http://www.*******.com/contact.html
Thanks!!
Diane
October 5th, 2008 at 1:08 pm
simply beautifull,lots of black/cold guiness to you
December 26th, 2008 at 5:44 pm
Hi,
I have tried to use the code, but when i test the form i always get the ERROR SENDING MAIL message…
What can i do about that?
greets
December 26th, 2008 at 6:54 pm
It sounds like you have either not uploaded the php script or your server does not support php.
December 27th, 2008 at 1:28 pm
Ok thanks it works…
But i have still one little problem I can not input the @ sign in my fields, because my shift btn does not work online at the contactform…
Do you know why this happens?
December 27th, 2008 at 5:28 pm
Make sure wmode is not set to transparent in the embed code of the html page.
December 28th, 2008 at 11:10 am
I can’t find that wmode… is it in flash or do i have to change that somewhere else.. I have embedded all inside flash, but that was not the problem…
December 28th, 2008 at 11:16 am
Can you post a link to your flash contact form?
December 28th, 2008 at 11:17 am
and the problem is just in FF not in IE…
December 28th, 2008 at 11:19 am
i have solved it
Thanks for all the help!
December 28th, 2008 at 11:27 am
How did you solve it so that others may learn.
December 28th, 2008 at 12:01 pm
publish settings > html> window mode
February 2nd, 2009 at 12:44 pm
when i test the html page with the swf embedded, i get this error:
Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
at Error$/throwError()
at flash.net::URLVariables/decode()
at flash.net::URLVariables()
at flash.net::URLLoader/onComplete()
February 2nd, 2009 at 12:46 pm
Did you change the path to the php script?
February 2nd, 2009 at 1:01 pm
the php file is in the same folder as the swf. still the errors popping up
February 2nd, 2009 at 1:05 pm
You may need to update the path to the php script in the fla and republish
February 21st, 2009 at 10:32 pm
thanks a million!
this is the ONLY online flash email form tutorial that works for me, and I’ve been searching for a php script that actually works for a very LONG time!!
to those of you who were lucky enough to stumble upon this site, you have no idea how lucky you are!
now I have my very own email form that runs like a dream, I am sure it’s gonna help me get more clients now that they can just request information directly from my form, thanks again for this truly wonderful tutorial!!
-hank
February 25th, 2009 at 1:31 am
I am working on a client site to try an get her contact sheet up and running. I am new to flash, but started on AS 3.0 because I know 2.0′s gonna get phased out some day. Everything seems to work up until the sending part. I hangs stating that it is sending the message please wait. I have modified the code to remove the gender part. Took that part out of the .php file. Her hosting is a 1 and 1.com site so I know they are Linux based and offer PHP, i just have no clue how to ensure that her PHP options for email related programming is working. I dont know a thing about .HTML or .PHP – just how to plug and swap values in notepad. Anyone have any clue of what I am doing wrong? Her directory on file Zilla looks like this: these are folders–>[]
[]… <—this goes to the server
[]_db_import
[]aspnet_client
[]db
[]logs
[]sss <— ALL of her website files are here [swfs,htmls,phps)
The folder called “sss” contains the swf files and the index.html file to make the site run. This is also where I have stuck the contact.php file, which the flash obviously recognizes because it plays just fine. I just cannot send. Please share what you know, if anyone has the time. Thank you SO MUCH for this upload. It is a life saver – now if I could just get it to work….
February 25th, 2009 at 9:34 am
If you can upload you fla and php script i will take a look and see whats going on.
February 25th, 2009 at 5:50 pm
hey thanks a lot for the file!
but ive got the same problem as will?! although i have entered my email into the php- file correctly as far as i know, it keeps hangig at the loading- animation…
both files are in the root directory and im not the webhost but i know that the server does support mysql, so it will support php, wont it?
it would be great if u could take a look at it.. fla is online as well(contactform.fla).
thanks a lot!alex
February 25th, 2009 at 6:04 pm
You need a cross domain policy file on the server that host’s the php script.
swf and php script are on different servers
March 2nd, 2009 at 6:47 pm
Hi, Paul.
I have tried your e-mail form, but i can’t get it to work. I am getting the error sending mail straight away. The server is runing linux and it is php enabled. Any sugestions mate? I am new to this game but very anxious to get this thing running.
Thanks in advance Paul!
March 2nd, 2009 at 6:56 pm
Can you post your fla and url to the php script.
March 2nd, 2009 at 7:25 pm
What Do mean by that?
March 2nd, 2009 at 7:30 pm
zip you fla and post a link to it here so that i cna download it and take a look and see what’s going on.
March 3rd, 2009 at 8:32 am
http://www.autobaltic.ie/e-mail.zip
Thanks for doing that for me!
March 3rd, 2009 at 8:45 am
line 14 in the php script:
$to = “admin@yourdomain.co.uk”;
Have you changed this to the email address you want the mail sent to?
I did a quick test and was able to submit the form. No errors reported.
March 3rd, 2009 at 9:03 am
Sorry.
That wasn’t my modified php file, my mistake. The other one was on the server. Try now.
http://www.autobaltic.ie/e-mail.zip
March 3rd, 2009 at 9:10 am
I can see it’s working for you! I Just got an e-mail
March 3rd, 2009 at 9:11 am
What am I doing wrong?
March 3rd, 2009 at 9:28 am
Where is $msgPost;
being set?
March 3rd, 2009 at 9:51 am
Where do i set it?
March 3rd, 2009 at 9:53 am
Your the one that modded the script. You tell me where you set it/.
March 3rd, 2009 at 10:05 am
Do you mean the line 18 in the php script?
March 3rd, 2009 at 10:23 am
yeah!
Where is $msgPost coming from?
March 3rd, 2009 at 10:29 am
I don’t know, i haven’t touched that line, wouldn’t know what to put there anyway.
March 3rd, 2009 at 10:35 am
ok can you re-post your source fla and php script please.
March 3rd, 2009 at 10:42 am
http://www.**************
March 3rd, 2009 at 10:45 am
CS3 please.
March 3rd, 2009 at 10:56 am
http://www.**************
Sorry
March 3rd, 2009 at 10:59 am
yeah man the source please!
i cant do anything with a swf
March 3rd, 2009 at 11:12 am
http://www.**************
Sorry, i am all over the gaf this morning, have a flu.
March 3rd, 2009 at 11:53 am
You where sent here to test me! weren’t you!
Where on your server is the php script? so that i can call it from this end.
March 3rd, 2009 at 11:59 am
Yeah, by the Lord Allmighty!
http://www.********
March 3rd, 2009 at 12:05 pm
ok it seems to be working fine for me. it must be an issue with you using flash CS4
March 3rd, 2009 at 12:18 pm
Right, i did moved all the files in the root directory including AC_RunActiveContent. All files cs3 based and it worked. I am now able to send the e-mails. Case closed.
You are the Man.
Very much appreciated, Paul.
Thanks very much.
Can i put your link in my site as special thanks to?
March 3rd, 2009 at 12:22 pm
T.G
Yeah sure you can
March 3rd, 2009 at 6:40 pm
Just a quick question Paul. I have to convert my flash cs4 website into cs3, since i want that e-mail form in it. Everything is going well untill the moment when in cs3 Dynamic text fiels on the screen appears in white background, i dont understand why. Static text apears as it should be – with transp. background. Any sugestions?
March 3rd, 2009 at 6:51 pm
check the properties of the textfiled and make sure that “show border around text” is not selected.
March 4th, 2009 at 8:56 am
Good Man! Cheers!
March 7th, 2009 at 7:56 am
Hi and thanks for a great contact form, works a treat. I have a problem trying to change the font of the text which appears after the form has been submitted ie while the php is working…eg
“please wait…” “form submitted”
Can’t find it anywhere. Everything else is fine. Once again thanks and grateful for any help. Best wishes Neil
March 7th, 2009 at 7:58 am
It’s there…
March 7th, 2009 at 7:59 am
Oops. amazing what you see when you look hard enough. Found it now, thanks. Forget the above post, except the part that expresses my thanks.
Cheers Neil
April 6th, 2009 at 9:15 am
Hii All..
My name is sagar.im working as a visualizer.i designed one flash website recently.in that website there is one contact us form where people can submit there comments and details.im not so good in PHP. but with the help of some php tutorial i did something.i did the testing in a linux server its working fine in Linux server.but when i updated that in the client’s server which is windows it not working.it says (Waiting for http://www.websitename.com) can any one help me?please
(i an including the link http://www.sagarenas.com/mail.zip where u can download the zip file which contains email.php and index.fla file)
April 6th, 2009 at 9:52 am
Does the windows server have php installed?
April 6th, 2009 at 12:04 pm
Yes the providers said both asp and php are enabled in the server.
April 6th, 2009 at 12:10 pm
check what the default email is in your php.ini file
April 6th, 2009 at 12:13 pm
Sorry i dont know anything about php.ini file..where is that file located?
April 6th, 2009 at 12:22 pm
Looked at your files.
Sorry i can only advise on files i have created.
April 6th, 2009 at 12:26 pm
ooh ok..anywys thanx for your reply
April 15th, 2009 at 6:34 pm
Hey Paul, I’m having some trouble with your contact form. I placed the mc in my flash file and linked the url request directly to the contact_parse on my server. I also changed the $to to my email address. My server is php enabled and it seems to work fine. Processing then the Thank You message yet I never get an email. Any help you could give me would be greatly appreciated. -Mike
April 15th, 2009 at 6:50 pm
Can you email the files to: paul[at]scotflash[dot]co[dot]uk
April 15th, 2009 at 7:43 pm
The files are 80mb so Im going to upload it to my server so you can download it from there. The contact form movie clip is on frame 20. I do apologize for my .fla being unorganized; more focused on this contact form atm. Thank you so much.
http://www…./~mbearden/goldsmith.zip
June 11th, 2009 at 10:13 am
Brilliant stuff…
Thanks
June 17th, 2009 at 1:18 am
I am using this script for my flash website. And I am stuck. I am getting error with the Send button.
Code in the script says:
//————–Set up form buttons
send_button.addEventListener(MouseEvent.CLICK, sendForm);
send_button.txTitle.text=”SUBMIT”;
My Question:
Where is txTitle in the flash Contact form? The error I get is “Access of undefined property send_button” and shows the about two lines in the source.
Please help! Thanks
June 17th, 2009 at 1:38 am
Oh my god! Can you guys believe this? I solved the errors and it is working all good. Horray!
Thanks
June 24th, 2009 at 2:19 pm
Hello,
The form is working very well, thanks for that. But i have one problem. when i recieve al mail, there are allot of brakes to read. Can i change this?
Thank you for helping me.
Greetings
June 24th, 2009 at 2:26 pm
allot of breaks?
July 8th, 2009 at 10:13 am
[...] the Simple flash AS3 contact form recently seeing over 5000 downloads I’ve decided to add a new [...]
July 20th, 2009 at 7:35 pm
Hi Paul,
Magic tut buddy, nice work.
Was just wondering if you knew how to collect the vars if thet are over several frames. Basically Ive expanded your form and have to many fields to fit on one sheet so I split it up into 6 frames with differant fields. I cant for the life of me work out how to collect the field veriables and then post them once im at the end of the form.
Any help would be greatly appreciated.
Thanks
July 20th, 2009 at 7:53 pm
I have one available for purchase here that does that. Hope it’s of some help.
August 11th, 2009 at 9:24 pm
Hello,
How do I change the font used on the buttons? Also, could you tell me how to get rid of that background after the form has been sent?
August 12th, 2009 at 7:06 am
Double click on the button and you will be able to select the textfield and choose a different font.
August 17th, 2009 at 2:25 pm
i have downloaded the file. was trying to put stuffs into my website. actually i dont need so many form details. i just need a email field so that user can put their email and click on send button and i get the email address in my email address.
i tried tweeking the code so as to remove the code for all other text fields.everything is fine but i get an error :
1120: Access of undefined property mcLoader.mcLoader.gotoAndPlay(2);
1120: Access of undefined property mcLoader.mcLoader.gotoAndStop(25);
1120: Access of undefined property mcLoadermcLoader.gotoAndStop(1);
i have seen in the library there is an empty mcLoader symbol.but am not able to figure out where it is and how is it useful?? can u please help?
August 17th, 2009 at 2:34 pm
ok i figured out what mcloader is..and i put it in the same movieclip which contains the email text field and send button. but still i get the same error message.
August 18th, 2009 at 7:41 am
Can you send me your fla?
August 27th, 2009 at 10:53 pm
Great! But what about two checkboxes selected (“(9am-12noon”, “3pm-6pm” ) best time to call and 4 radio buttons selected one (“Home”, “Work”, “Fax”, or “Mobile”) phone to be validated on simple Flash AS3 contact form using UI components? How? I get errors—looping form!!!
September 3rd, 2009 at 3:45 pm
Cool!!, I have found another simple Flash AS3 code for flash contact us form may be you guys would like to have look on that.
http://www.msinghinteractive.com/blog/?tag=as3-contact-us-form
September 8th, 2009 at 1:17 am
It works until I try adding fields that were not in your original FLA. For example, I removed the gender inputs and added a “Phone Number” field to the form, and modified the AS3 and PHP accordingly. After submission, it just hangs on “Sending…”. I’ve been racking my brain for a solution but I can’t figure out why this error is occuring. Any guidance?
September 8th, 2009 at 6:45 am
Can you send me your fla please?
September 9th, 2009 at 2:03 am
Actually that won’t be necessary. I made a new PHP file from scratch and got it working how I needed it to (not saying yours doesn’t work well, I just needed to go thru it line by line). I appreciate the speedy response though. And thanks for sharing your code, I wouldn’t know where to start on A LOT of things if it weren’t for people like you. Keep up the good work.
September 30th, 2009 at 5:25 am
does this support mail sendin to gmail?
September 30th, 2009 at 6:48 am
The server config dictates what email address the form will send to not my script. Some servers will only allow you nto send me to a email address linked to the domain where the form is hosted.
October 26th, 2009 at 10:47 am
Hi,
I am currently creating my website at google. I am using flash but can not create contact form as google does not allow php script.
Is the anyway in which I can use contact form by using other server for hosting php file. Ur help is highly appreciated. Please keep in mind I am not very familier with flash but I can follow instruction and find my way around.
Many thanks
vapn
October 27th, 2009 at 9:33 am
Yes you can use another server hosting the php script. As long as the other server has a crossdomain.xml file on it then there should be no problems.
October 28th, 2009 at 5:32 am
thanks for your advice,
Is it possible for you to suggest any free server which allows cross domain and also allow for php hosting (for contact form only)
many thanks,
vapn
October 28th, 2009 at 9:26 am
No i am sorry i don’t know any that are free.
I did a search for “Free php hosting”
Hope it is of some help.
October 28th, 2009 at 11:38 pm
paul,
many thanks for your time and help
regards,
vapn
October 29th, 2009 at 12:51 pm
Hi Paul,
First of all thanks for this excellent contact form, and especially giving it away free to a numpty like me!!
I’ve successfully added it to my flash website, and it works without any problems. However, if a user selects fullscreen mode, they can’t enter text in any of the text fields. I’ve come up blank with the reason for this, perhaps you can help?
Have a look at a draft of my site here to see what I mean: http://www.thepictureprinciple.com/flash/index.html
Thanks
Andrew
October 29th, 2009 at 2:38 pm
Hi Andrew.
There is limited input for flash in fullscreen mode. You an read more about it here.
There is no work around.
November 6th, 2009 at 8:44 pm
thanks a lot man! Great job!
best regards,
Luciano
November 17th, 2009 at 12:24 am
Hi Paul,
thanks a lot for this. Unfortunately it isn’t working for me
. The emails are submitted, but I never receive any of them.
I just used your form and put in my email adress. Do you have any idea what I could do?
Thank you very much
Bianca
November 17th, 2009 at 8:32 am
Did you add your email address to the php script
December 1st, 2009 at 12:57 pm
hey thanks a lot this works like a charm!!! indeed first working contact form i encounter!
December 3rd, 2009 at 9:33 pm
I’m no pro with this flash mail form stuff.
Everything seems to work fine BUT:
I get the message to my inbox but I can’t reply to the user because the mail form doesn’t forward the users email address.
Am I missing something?
December 4th, 2009 at 11:50 am
Would you be able to email me over the files your working?
My script does forward the user’s email address.
All you have to do is hit reply to the email.
December 22nd, 2009 at 12:37 pm
Hi,
I`m loving the form and the flexibility it has. It`s really easy to decorate it the way i want. Exactly what i needed. I`m having a question that concerns more the flash itself. Is it ever possible to make the message textfield not starting from the second line. It`s a problem I`ve been digging for a long time now, and if there is someone here to tell me the secret, i`d be one of the happiest humans on the planet. Thank you
December 22nd, 2009 at 12:49 pm
Hi there,
Set txMessage.text=”";
Just below txMessage.tabIndex = 2;
January 1st, 2010 at 12:30 am
This works great! thanks, I learned a bit of this
January 14th, 2010 at 4:13 pm
I finaly found out that i need to change wmode to window, but now the problem is that i need the flash to be transparent. is there a way to change to transparent WITHOUT missing the characters from my norwegian keyboard??
January 15th, 2010 at 8:43 am
Sorry not to my knowledge
January 19th, 2010 at 6:20 pm
Can you tell me, please, what version php is used?
January 19th, 2010 at 7:16 pm
It should work with any version. Script has been tested on a server with php4 and php5
January 20th, 2010 at 2:56 am
But why does it have to set it on non transparent, do you have any idea of how to fix the problem. couse now I can not input the @ sign in my fields, because my shift btn does not work online at the contactform…
January 20th, 2010 at 7:45 am
It’s not a problem it’s just the way it is. Also you might want to double check paths for your swf
http://www.lysglimt.no/flash/lysglimt_flash-web.swf
404 not fond at this location.
February 9th, 2010 at 8:59 pm
Hi,
i have one error with the txTitle and i don`t found it.
please help me.
thanks
February 9th, 2010 at 9:38 pm
The files work as is. Without seeing the source and seeing what changes you made i can’t help with your error.
March 25th, 2010 at 11:58 pm
Hi Paul,
Your Form is awesome. Thank you for doing this.
The only issue I have is that I can easily add new fields to my form and alter the ActionScripting. When I test it, it works fine but the fields end up being required. If I don’t fill out those extra fields the form won’t go through.
My Example:
//————–Validate fields and submit form
variables.senderHandle = txNickname.text;
–If I add this new field to the varialbes the form works fine but it has to be filled out. If it’s not filled out on the form the form won’t go through. So I just want to make it optional.)
–I am not even adding the new variable to the “txErrorCheck” coding.
So i figured if I don’t put it in this part of the code… the field can be left blank and not checked for an empty area.
So my question is can you tell me how to add at least one non-required text field to the ActionScripting side of the code??
So it can be left blank on the form…
I can figure out how to add more if I just have one example…
Thanks a million..
March 26th, 2010 at 12:00 am
Sorry, i didn’t type my example properly.. it should have been..
My Example:
//————–Validate fields and submit form
variables.senderNickname = txNickname.text;
Thanks.
March 26th, 2010 at 9:50 am
All you need to do is remove the validation check on the txNickname field.
I am assuming that you have added the relevant code to accommodate the new field?
April 2nd, 2010 at 3:31 pm
Hey Paul,
I was reading over this and it seems you know quite a bit. I’ve read up on some AS3 to PHP scripts for email sending.
I have a PHP script that i currently use to send emails from a html form, but i want it to work for my SWF form now. I get no errors when compiling the flash form.
When i click the submit button. It just sits there. I don’t receive an email or anything, i don’t have a validation for anything, but i figured that wasn’t needed to just get this form going.
any ideas? if you need i’ll post my .fla and php scripts aswell.
April 2nd, 2010 at 3:51 pm
Yeah I would need to see your fla and php script before I would know what’s going on.
April 2nd, 2010 at 4:28 pm
FLA & PHP
you might have to ALT click the link….
April 2nd, 2010 at 4:28 pm
Thanks Paul
April 2nd, 2010 at 5:01 pm
link not working
April 2nd, 2010 at 6:10 pm
? when i alt click it or shift click it it’ll download for me.
April 2nd, 2010 at 6:11 pm
oooo hrmmm invalid or corrupted.. haha
April 5th, 2010 at 7:08 pm
Hey Paul, was wondering if you had an idea of what might be causing that issue that Trever posted.
April 5th, 2010 at 8:07 pm
unable to comment without seeing the files.
April 5th, 2010 at 8:28 pm
lmao.. Gotcha..
Well here are the codes
http://www.kirupa.com/forum/showthread.php?t=346599
I posted them on there.
April 11th, 2010 at 8:33 am
great work
April 22nd, 2010 at 12:13 pm
Hi
I have a flash pages on line and need to add the code for the form , hope you can help me.
thanks
r
April 22nd, 2010 at 12:22 pm
Hi,
Can you give some more information please?
June 3rd, 2010 at 11:01 am
mate, i’ve been through so many of these tutorials and downloads looking for one that works. having to change bits here and there with no success (normally things labelled as3 when they’re as2)
this one did first time!
nice one and ta for sharing
June 11th, 2010 at 6:22 pm
this works awsome, im trying to add a combobox with some data in it where i nput the values through the component from within the ide at design time but i can’tseem to get a basic combo box values to be included in the mail.
if anybody can help with a basic combo box i would really appreciate it.
tnx
June 11th, 2010 at 8:05 pm
If you send me your fla i will take a look.
June 11th, 2010 at 10:49 pm
k! i finally got it nice mail script heres what i had to do incase anyone else needs it.
1: i created a crossdomain.xml for goddady
2:flash combo
program.addEventListener(Event.CHANGE, ShowSelectedItem);
}
function ShowSelectedItem(event:Event):void {
hidtext.text=program.selectedItem.label;
}
added to contact.php
$senderhidtext =$_POST['senderhidtext'];
then added to the message being sent.
tnx so much for this awsome flash file code
sending mail within godaddy has issues so created the crossdomain.xml and works 100%
July 6th, 2010 at 1:00 pm
Hi Paul,
Thanks for the form. It works quality. I have hosting with 1 and 1 and got it to work perfect 1st time so I must thankyou.
However, I am also using hosting with Freedom 2 surf. I have changed nothing and can’t get it to work!
I have contacted them and they have a linux server and PHP is supported and the PHP file can be anywhere on my server.
I have read some comments above about putting the full path to the PHP in my flash file and tried loads of different things but still no joy.
Hope you have some advice.
Cheers
Steve
July 6th, 2010 at 1:38 pm
Hi,
Some server configurations require the email address used to send the email in the form is that of the same domain name the script is on.
so for example you might have it set up like
http://www.somedomain.com and in the script you have random@email.com. some servers don’t like this.
If this is what your doing then try adding ini_set (“sendmail_from”,”your@email.com”);
Obviously changing your@ for your own email.
If this is not the case can you send me a direct link to the php script on the server. DO NOT paste the link into the post. Email it to me via my email form.
Regards,
Paul
July 6th, 2010 at 2:09 pm
Hi Paul,
Thanks for your comments. I have just sent you a link to my php file on the server.
I am new to PHP and not sure about the ini_set….
Hope you can help.
Thanks
Steve
July 6th, 2010 at 3:30 pm
Hi Paul,
Thanks for your email. please see this link
http://www.freedom2surf.net/help/webhostingtechfaq.php
Hope you cans shed some light!
Steve
July 7th, 2010 at 10:52 am
Hi Paul,
Thanks for all your help yesterday. I am not getting loads of emials coming through but the flash file remains on the screen ‘sending mail…’
It doesn’t get to the form submitted part!
Hope you can help.
Steve
July 7th, 2010 at 11:12 am
Change the path in the fla from http://www.yourdomain.com/contact.php to just contact.php
July 7th, 2010 at 11:29 am
I Now get the error message but the mail still comes through!
July 15th, 2010 at 9:51 pm
I’ve been racking my brains out since yesterday and still no ideas are coming. people have been helping me and giving me bits of codes but still, nothing works…
but this is PERFECT! finally got it to work . . .
thanks a lot for sharing . . .
July 21st, 2010 at 7:12 am
Mate – a big big thanks to you!! I’m new to AS3 and I needed to see some working code so I could debug a simple form I’m working on. (Well, it was supposed to be simple…) Cheers for the headsup – from a fellow Scot in Australia!
August 12th, 2010 at 8:51 am
Hi I am getting the following error:
I am using WAMP server and have put the swf file and contact.php in the same root www directory.
Load failed: HTTP Status = 0
Load failed: IO error: Error #2032: Stream Error. URL: localhost:80/contact.php
Please help.
Thank you!
August 12th, 2010 at 9:02 am
Sorry can’t comment on any files running on WAMP. All my files have been tested on both Linux and windows dedicated servers without any issue’s. That’s all I can say.
August 12th, 2010 at 9:28 am
sorry i changed the following
var req:URLRequest = new URLRequest(“http://127.0.0.1:80/contact.php”);
but i’m getting ** Error sending mail **
I did a trace(evt.target.data)
and found the following
%3Cbr%20%2F%3E%0A%3Cb%3ENotice%3C%2Fb%3E%3A%20%20Undefined%20variable%3A%20msgPost%20in%20%3Cb%3EC%3A%5Cwamp%5Cwww%5Ccontact%2Ephp%3C%2Fb%3E%20on%20line%20%3Cb%3E18%3C%2Fb%3E%3Cbr%20%2F%3E%0Aretval=1
I am not getting any emails through.
how should i change the contact.php?
Thank you
August 12th, 2010 at 9:34 am
Yeah this is the readable error
Notice: Undefined variable: msgPost in C:\wamp\www\contact.php on line 18
So you have not passed msgPost in flash to the php script.
August 13th, 2010 at 6:19 pm
Hi Paul,
thx for code but I’ve got a problem with ff. I tried it in IE and only one time I received the msg from the form. I’m using CS4. Any idea?
Thank you
August 13th, 2010 at 7:23 pm
Hi,
Sorry without seeing what modifications you have made to the file or a link to somewhere i can test myself it is hard to say what your particular issue is.
August 14th, 2010 at 8:19 am
Hi, here is the code and the php :
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset238{\*\fname Arial;}Arial CE;}}
{\*\generator Msftedit 5.41.15.1515;}\viewkind4\uc1\pard\lang1051\f0\fs20 //—————Setup variables\par
var loader:URLLoader = new URLLoader();\par
var req:URLRequest = new URLRequest(“contact.php”);\par
var variables:URLVariables = new URLVariables();\par
loader.dataFormat = URLLoaderDataFormat.VARIABLES;\par
req.method = URLRequestMethod.POST;\par
var gender:String=”";\par
var senderRpl:String=”No”;\par
//————–Set tab index\par
txName.tabIndex = 0;\par
txEmail.tabIndex = 1;\par
txSize.tabIndex = 2;\par
txPocet.tabIndex = 3;\par
txMessage.tabIndex = 4;\par
//————–Set listener fot textfield changes\par
txName.addEventListener(Event.CHANGE, txErrorCheck);\par
txEmail.addEventListener(Event.CHANGE, txErrorCheck);\par
txSize.addEventListener(Event.CHANGE, txErrorCheck);\par
txPocet.addEventListener(Event.CHANGE, txErrorCheck);\par
txMessage.addEventListener(Event.CHANGE, txErrorCheck);\par
function txErrorCheck(event:Event):void \{\par
\tab if (txError.text.length>0) \{\par
\tab\tab txError.text = “”;\par
\tab\}\par
\}\par
//————–Set checkbox\par
cb.addEventListener(MouseEvent.CLICK,setReply);\par
function setReply(event:Event):void \{\par
\tab senderRpl=”Yes”;\par
\}\par
//————–Set radio buttons for gender\par
rad1.addEventListener(MouseEvent.CLICK, changeHandler);\par
rad2.addEventListener(MouseEvent.CLICK, changeHandler);\par
function changeHandler(event:Event):void \{\par
\tab gender=event.currentTarget.label;\par
\}\par
//————–Set up form buttons\par
butSend.addEventListener(MouseEvent.CLICK, sendForm);\par
butSend.txTitle.text=”OBJEDNAT”;\par
butReset.addEventListener(MouseEvent.CLICK, resetForm);\par
butReset.txTitle.text=”RESET”;\par
//————–Validate fields and submit form\par
function sendForm(evt:MouseEvent):void \{\par
\tab if (txName.text.length<=0) \{\par
\tab\tab txError.text = "** Chyba meno **";\par
\tab\} else if (!txEmail.text.length || txEmail.text.indexOf("@") == -1 || txEmail.text.indexOf(".") == -1) \{\par
\tab\tab txError.text = "missing field/Invalid email";\par
\tab\} else if (txSize.text==""||txSize.text.length<=1) \{\par
\tab\tab txError.text = "** Chyba velkost **";\par
\tab\} else if (txPocet.text==""||txPocet.text.length<=1) \{\par
\tab\tab txError.text = "** Chyba pocet **";\par
\tab\} else if (txMessage.text==""||txMessage.text.length<=1) \{\par
\tab\tab txError.text = "** Chyba adresa **";\par
\tab\} else if (gender=="") \{\par
\tab\tab txError.text = "** Prosim oznacte product **";\par
\tab\} else \{\par
\tab\tab mcLoader.gotoAndPlay(2);\par
\tab\tab variables.senderName = txName.text;\par
\tab\tab variables.senderEmail = txEmail.text;\par
\tab\tab variables.senderSize = txSize.text;\par
\tab\tab variables.senderPocet = txPocet.text;\par
\tab\tab variables.senderMsg = txMessage.text;\par
\tab\tab variables.senderSex = gender;\par
\tab\tab variables.senderRpl = senderRpl;\par
\tab\tab req.data = variables;\par
\tab\tab loader.load(req);\par
\tab\tab loader.addEventListener(Event.COMPLETE, receiveLoad);\par
\tab\}\par
\}\par
function receiveLoad(evt:Event):void \{\par
\tab if (evt.target.data.retval == 1) \{\par
\tab\tab mcLoader.gotoAndStop(25);\par
\tab\} else \{\par
\tab\tab mcLoader.gotoAndStop(1);\par
\tab\tab txError.text="** ERROR SENDING MAIL **";\par
\tab\}\par
\}\par
//————–Reset form\par
function resetForm(evt:MouseEvent):void \{\par
\tab txName.text="";\par
\tab txEmail.text="";\par
\tab txSize.text="";\par
\tab txPocet.text="";\par
\tab txMessage.text="";\par
\tab cb.selected=false;\par
\}\par
stop();\par
}
and PHP :
<?php
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
if(empty($_POST['senderEmail'])){
echo"no email address found";
exit;
}
$senderName = $_POST['senderName'];
$senderEmail = $_POST['senderEmail'];
$senderMsg = nl2br($_POST['senderMsg']);
$senderSize = $_POST['senderSize'];
$senderPocet = $_POST['senderPocet'];
$senderSex = $_POST['senderSex'];
$senderRpl = $_POST['senderRpl'];
$sitename = "www.nanakupe.sk";
$to = "obchod@nanakupe.sk";
$ToName = "info";
$date = date("m/d/Y H:i:s");
$ToSubject = "Objednavka od $senderName z $sitename";
$comments = $msgPost;
$EmailBody = "A visitor to $sitename has left the following information
Objednavka: $senderName
Produkt: $senderSex
Velkost: $senderSize
Kusov: $senderPocet
Adresa:
$senderMsg”;
$EmailFooter = “Sent: $date”;
$Message = $EmailBody.$EmailFooter;
$ok = mail($to, $ToSubject, $Message, $headers . “From:$senderName “);
if($ok){
echo “retval=1″;
}else{
echo “retval=0″;
}
thanks a lot.
August 14th, 2010 at 8:46 am
ok it might be easier if you just send me the fla and php script.
August 14th, 2010 at 2:49 pm
I’ve solved the problem. Thx a lot for your interest.
August 14th, 2010 at 3:10 pm
What was the problem with the contact form?
August 14th, 2010 at 3:19 pm
I tried to implement form to the existing project. May be I did there some mystake. Actually I have a two projects.In the 1st project I just put a link via button to the 2nd project.