PHP and MySQL Code

Start typing to search for PHP and MySQL Code Snippets and Articles Search

Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder

Go Back Add a Comment Send this Article to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
Title : Creating a Mail Form with PHP and Flash
Categories : PHP, Flash, Mail
Date : 2003-03-21
Grade : 5 of 5 (graded 1 times)
Viewed : 22099
Search : More Articles by codewalkers
Action : Grade This Article
Tools : My Favotite Articles

Submit your own code examples 


In this tutorial we are going to show you how to create a contact form within flash and send it using PHP.

Click here to download the source for this tutorial.

First of all a few requirements.
This tutorial is written for Flash 5 and obviously your server must support PHP Download the source file and open it and have a study it as we go through this tutorial, it will make it easier to understand.

Ok Lets get started!

The Form
Open the source file and you will notice the following:

The movie has 2 frames both with stop() actions within them. The first frame contains the form , the second frame has the thank you message.

Now lets look at the form itself.

The form has four text fields whose variable names from top to bottom are name, subject, message and e-mail.
It also has 2 buttons, a send and a clear button, both with actions on them (we shall cover those later)

Text Fields
So how did we create the text fields?

From the Flash menu go Windows>Panels>Text options.
The box below will open, Select the Text Options tab.

From the Top drop down menu you have 3 options :
Static text, Dynamic Text and Input text.
In this case we need to select the Input text option.

The second drop down menu also has 3 options
Single Line, Multiline, Password.
You would select the Single line option for all the fields except the message field.

The Third and last option is perhaps the most important and that is the Variable name. If you look at the source file you have downloaded then you will see to keep it simple the field where you enter your name is called name, subject is called subject and so on.

So we have created our text fields and given them names, what about our buttons?
First of all lets look at our clear button.

All I have done is create a simple button, and given it the following actions.

on (release) {
name = "";

Let's go through the code

on (release)
Perform these actions when this button is clicked then released

name = "";
The fields with the variable name above will have this value (empty)
Ok lets have a look at the send button

More Buttons
Next the send button

Again I have just created a simple button and assigned it the following actions :

on (release) {
if (name eq "" or subject eq "" or message eq "" or email eq "") {
stop ();
} else {
loadVariablesNum ("form.php", 0, "POST");
gotoAndStop (2);

Let's go through the code Line by Line
on (release)
Perform these actions when this button is clicked then released

if (name eq "" or subject eq "" or message eq "" or email eq ""){
Check to see if the fields don't have a value.

if one of the fields doesn't have a value then stop.

} else {
if all the fields have a value(filled in) then carry on.

loadVariablesNum ("form.php", 0, "POST");
Send variables, using the POST method, to our PHP script which will send the e-mail

gotoAndStop (2);
Go to the thank you message and stop once the e-mail has been sent.

So we have our text fields and we have our buttons with the necessary actions.
Now we need to write the script to send it with.

On to the PHP Code
Next we will turn our attention to our PHP file.

Open up your favourite text editor or WYSIWYG program and copy this code.

= "[email protected]";
$msg = "$name\n\n";
$msg .= "$message\n\n";
mail($to, $subject, $msg, "From: My web site\nReply-To: $email\n");

Again let's break down this code line by line.

$to = "[email protected]";
Here we are setting a variable with your e-mail address as it's value.

$msg = "$name\n\n";
$msg .= "$message\n\n";
This is what will be displayed in the body of our e-mail.
The variable name and message are defined in the flash file

mail($to, $subject, $msg, "From: My web site\nReply-To: $email\n");
mail() is a great function in PHP . It's syntax is
mail("recipient", "subject" , "message", "mailheaders")
The variable $subject and $email are also defined in the flash file

Save your file as form.php

Finishing it off
So what is there left to do?

Just upload the files to a web server with PHP support.

Remember that you can't run these files locally unless you are running some sort of web-server with PHP support.

Hope you enjoyed this tutorial

Creating a Mail Form with PHP and Flash - Part 2
Categories : PHP, Flash, Mail
Flash 4 and PHP - Retrieving Text From a Database
Categories : PHP, MySQL, Flash
Getting Intimate With PHP's Mail() Function
Categories : PHP, Mail, PHP Functions
Sending Mail Using Flash 4 and PHP
Categories : PHP, PHP options/info, Flash
10 PHP Functions I Bet You Didn`t Know About
Categories : PHP, PHP Functions, Filesystem, Arrays, Errors and Logging
PHP 101 Part 2 of 15 : Calling All Operators
Categories : PHP, Beginner Guides, Operators
Object Oriented Programming in PHP
Categories : PHP, Object Oriented
Working with Dates and Times in PHP
Categories : PHP, Date Time
PHP for Beginners by a Beginner: Simple Login, Logout, and Session Handling
Categories : PHP, Sessions, Authentication
Using If Else Statements
Categories : PHP, Beginner Guides
Simple Form-Based File Uploads
Categories : PHP, File System
PHP Browser Detection and Appropriate CSS Generation
Categories : PHP, Browsers, CSS
Web database Information Flow
Categories : PHP, MySQL
An Introduction to Pear
Categories : Pear, PHP
Using PEAR HTML_Template_IT For Modular Interface Design
Categories : PHP, PEAR, Templates