How to make a PHP Flash Contact Form
July 7, 2009 by: EDSWhat we do
In this tutorial we will learn how to make a simple and effective PHP Flash Contact Form using Action Script 2.0
Step 1
First create a new file using Action Script 2.0.
Hit CTRL + J (Document Properties) or go to Modify – Document and change your settings like in picture below:
Now we must create only the structure of our contact form. We will use the Text Tool (T) and start writing and construct.
First E-mail + Text Field, second Subject + Text Field, third Message + Text Field.
Text Field must be Input Text. I will show you later, now you must have a similar structure like in the picture below:
Now you must set your Text Field with the following settings (click to view larger image)
Now we need a Scroll Bar for Message Field. If someone have a very long message what we can do? Simple.
Go to menu Window – Components (CTRL + F7). On the User Interface rollout you will find UIScrollBar.
Drag and drop it near Message Field and go to Parameters Rollout and near _targetInstanceName write message_field.
Step 2
Good now we must draw a Send button using Rectangle Tool (R) and with Text Tool add a text with “Send”.
Select both and press F8 to Convert them to Button and click OK.
Very good now we must create the Error Message if something is wrong.
With Text Tool write “All fields required !” and select it, then press F8 and Convert it to MovieClip, and put the instance name “error_clip”
Ok we almost finished with the design and structure. The only thing left is to create a background for Text Fields.
To do that select Rectangle Tool and draw the same size with a dark color.
Border with #555555
Background with #222222
The final structure should look like in the picture below:
Step 3 – Coding
Looks nice no? Now we must make him work !
Select the first frame and press F9 (Action Script Panel) and insert the code below:
// www.extremestudio.ro – PHP Flash Contact Form
// Loading Variables and Settings
stop();
error_clip._alpha = 0;
System.useCodepage = true;
send_btn.onRelease = function() {
my_vars = new LoadVars();
my_vars.email = email_field.text;
my_vars.subject = subject_field.text;
my_vars.message = message_field.text;// If text fields are not blank the message will be sent
if (my_vars.email != “” and my_vars.subject != “” and my_vars.message != “”) {
my_vars.sendAndLoad(“send_mail.php”, my_vars, “POST”);
gotoAndStop(2);
// Else if text fields are blank a warning message will appear
} else {
error_clip._alpha = 100;
}
// After the message is sent the user will be redirected to frame 3
my_vars.onLoad = function() {
gotoAndStop(3);
};
};
// If you click on another field “All Fields Required” will dissapear
email_field.onSetFocus = subject_field.onSetFocus = message_field.onSetFocus = function () {
if (error_clip._alpha != 0) {
error_clip._alpha = 0;
}
};
Go to Timeline and create 2 New Frames by pressing F6.
Select Frame 2 and DELETE ALL except the title and put a text with ” Sending Message…” and make a animation.
Select Frame 3 and DELETE ALL execept the title and put a text with ” Message Sent. Thank you for contacting us” or any message you want. Press F9 and put stop(); in the Action Script Panel to stop the form playing again.
You should have this:
That’s all with Flash ! We need to create the PHP File.
Open Notepad or any software you have (like Dreamweaver) and write the code below:
<?php
// Extreme Design Studio – www.extremestudio.ro
// PHP Flash Contact Form – PHP Script
// Loading Variables
$email = “E-mail: “ . $_REQUEST["email"] . “\n\n”;
$subject = $_REQUEST["subject"];
$message = “Message: \n—\n” . $_REQUEST["message"] . “\n\n”;
$ip = “IP: “ . $_SERVER['REMOTE_ADDR'] . “\n”;
// The \n character means New Line// Mixing all variables, including IP
$full_message = $email . $message . $ip;// Remove the backslashes that appears when entering characters like ” or ‘
$message = stripslashes($message);
$subject = stripslashes($subject);
$sender = stripslashes($sender);// Sending the mail
// Note: Don’t forget to change “your@email.com” to receive the mail from contact form
mail(“your@email.com”, $subject, $full_message);
?>
Save this file as: send_mail.php
Note: The .swf and .php file must be in the same folder!
That’s all ! Your PHP Contact Form should look like in example below. Enter your email and send a message yourself to test it!
Test it !
Download Files
You have reached the end of the post. You can try the similar posts below.
|
|
|
|
Comments (38 Comments)
38 Responses to “How to make a PHP Flash Contact Form”Add your Comment
































Thank you. Enjoy reading our site and don’t forget to subscribe for more great tutorials.
Hi there, your tutorial is GREAT!
The only problem is that the alfa=0 property fot the Movie Clip “error_clip”" is not working.
The text shows on my form and if I leave a field black and click Send nothing happen.
The text “All fields Required” is a Moviel Clip with an instancename error_clip.
Thanks a lot
Hello sir my name is sanjay kumar i am currently operation http://www.moneyinhands.com i don’t idea about how i create php form for my website with spam protection. Current i am using php form from emailmeform.com but i need my own php form code. Please tell me or suggest me how i create php form to i use for my all website. I am waiting for kind suggestions…
Hello Sanjay. You can make a a custom php form with protection using some Javascript. I will do a tutorial with this in my next tutorial.
hey, thanks for the tutorial. i’m having the same issues as everyone else it seems. the all fields required section shows up at the beginning and emails don’t get sent. it also seems that you have to tab down to the send button. if you try to just click it it selects text. any help with this? thanks.
What errors do you meet exactly? I can’t figure what is the problem in your comment. Do you have an example of your project?
yes. http://www.myspace.com/aspectinc is the page i\’m trying to insert the contact form on. i\’ve deleted the text for required field to get rid of it but the emails are not being sent..both are hosted in the same folder but for some reason i\’m not recieving the test forms.
I saw the contact form on your site. The send_mail.php file is there ? You need the both files to work correctly and you must write the action script and php code corretly. Can you send me all the files in a .zip file ? You will find my e-mail on the contact page. Thank you.
hELLOOOO!!
Thanks for your great Tutorial… Is really well explained…!!!
Hey I just created my website with Flash and I added your contact form… but is not working. I receive nothing!!! You can check the website at: http://www.novelda-marmol.com
I don’t know why!!?? This is driving me crazyyyy!! heheh
I think I just follow the exact same steps as you explained.!
Maybe you wrote something wrong in the php or action script code. Check twice. If you followed all the steps carefully the contact form will work.
hello. great tutorial.
everything seems to work just great… no errors in the codes… the animation shows up just well…
but it doesn’t send emails.
i have checked several times, line per line, to see if there was any mistake. but everything is just in the same way you did it.
if i don’t fill in the fields it, it won’t stop and it won’t show the error clip. it just goes to the 3rd frame with the thank you message.
that’s all it does.
and even if i fill in all the fields, the message is not being sent anyway.
i can’t see where the problem is. any idea? besides from checking the AS or php code again?
T.I.A.
Yes besides from checking the A.S. or PHP Code again is to check if all the symbols and animations are correctly placed in your frames. After your project will work well you should check your server and see if it supports PHP 5.
In the action script code ,we are validating whether mail id is not blank,instead we should check whether the mail id is valid one. . . .
shouldn’t this line in php ($sender = stripslashes($sender);)
be
$email = stripslashes($email);
Hi, great tutorial, thank you.
This is driving me crazy however. I set it all up, it worked perfectly and sent me an email….once. The very first time I tested it it worked. Without changing ANYTHING at all, it no longer sends me any mail. It all functions properly, it just doesnt ever show up in my mail box. I’ve tried 4 different email accounts (aol, google, hotmail, etc) and none of them receive it. What could be the problem?? Thanks!
Hello my friend, there isn’t any line in PHP as you written. Thank you. I double checked.
Hello Nicholas. If you tested and worked perfectly, maybe you accidentally deleted a code line or something is missing. Double check everything.