Advanced Search
Keywords

The BoxedArt Guide to Using Website Templates



Getting a Contact Form to Submit with a Formmail Script

Setting Up an HTML Contact Form

First, download and extract the the php form mail script. After the script is extracted, in a text editor such as Notepad, open the formmail-php.php file.

Follow the instructions in the formmail-php.php file for customizing variables and entering the email address where you want to receive messages from the form. Save the formmail-php.php into the same folder as your .html files.

Next, open the html file from your template that has a contact form in it.

In the HTML source code, just beneath the top <body> tag, put these two tags:

<form method="post" action="formmail-php.php">
<input type="hidden" name="send" value="1" />

Then, also in the html file's source code, locate the template's "send" button image, which could look like this:

<img src="../images/b_send.gif" />

Change the image to a form element so the tag reads:

<input type="image" src="../images/b_send.gif" />

And lastly, just above the closing </body> tag at the bottom of your page's source code, type

</form>

Save both the formailphp.php and the html files, and upload them to the same folder on your web server.

Setting Up a Flash Contact Form

First, download and extract the the php flash form mail script. After the script is extracted,Open the flashformmail.php in a text editor such as Notepad.
Where it says --
= "you@yoursite.com";
= "My Flash site reply";
-- type in the email address where you want to receive mail from the form and the subject header of your choice.
File > Save to save the flashformmail.php file. Save it to the same folder as the .swf file(s) of your site.

Next, launch Flash and open the .fla file that contains the form.

The Input text fields in your Flash movie's form need to be combined into one MovieClip symbol. To do this:
Choose the black arrow tool from the toolbar and, holding down the Shift key on your keyboard, click on each of the Input text fields to select them all at once:

form

When the text fields are selected, press the F8 key on your keyboard to bring up the Convert to Symbol box.
Give it the name form and select Movie clip as the type:

form

Click OK to close the Convert to Symbol box.

With the "form" MovieClip selected on the stage, give it the Instance name of form in the Properties panel:

form

With the "form" MovieClip still selected, go to Edit > Edit in Place from Flash's top menu. This takes you inside the MovieClip's timeline.

You will now select each of the Input text fields and give each a variable name in the Properties panel. For the field where your site visitor will enter his or her name, the variable is name as shown here:

form

For the Input text field that will have the visitor's email address, select the text field and give it the variable email

For the Input text field that will have the visitor's message, select the text field and give it the variable message

Next, click on the Send button to select it. Note - make sure the word Send is actually a button and not just text. With it selected, look in the Properties panel to see what type of item it is. If it says "Static Text" or "Dynamic Text", or "Graphic" or "Movie clip", you need to convert it to a button symbol. To do this, make sure it's selected on the stage, and then press the F8 key on your keyboard. In the Convert to Symbol box that opens, name it send and choose Button as the type:

form

Click OK to close the Convert to Symbol box.

And lastly, you'll assign the ActionScript. With the Send button still selected on the stage, open the Actions panel. Make sure it says Actions - Button at the top. Give it the following script:

on (release) {
form.loadVariables("flashformmail.php", "POST");
}

Save your .fla file, and press the Ctrl and Enter keys on your keyboard to create the new .swf file. Make sure to move or copy this new .swf file into the same folder as any .html, other .swf files (and the flashformmail.php file) that make up your site.


Back to Design Tutorial