Introduction
Here we will cover the process involved in making a very
simple email form in Flash using PHP. Be aware that
Flash alone is incapable of sending email. PHP, or some
other server-side script like PHP, is needed to handle
that operation. Put the two together, though, and you
got yourself a great way for people to email you
directly through your Flash-based web site.
|
|
[ send me an email using Flash and PHP ]
How it Works
Because PHP is being used to send an email, Flash needs a
way to communicate to PHP to let it know when to send an
email and with what information. Flash relies on PHP to
handle the email sending responsibility. When a Flash movie
is ready to have an email sent, it needs to talk to a PHP
script on the server so that script can then instruct the
server to send the email with the information provided.

[ Flash movie to PHP to server sending out email ]
A way Flash can send information to an external PHP page is through the loadVariables Actionscript command. This allows Flash to open a page on the server, like a PHP script, and send it specific information that allows you to control how that script behaves. In the case of this tutorial, to have a PHP script email information inputted in a Flash form. Flash sends the PHP page the information filled out in the form. The PHP script then inserts that information into a mail function which instructs the server to send an email with that information to the email address specified. Easy enough, right? Lets begin creating the Flash form.
Steps to Create Form
The Flash form consists of 2 basic parts. One part is the
group of text fields that make up the form. These are
actually contained within a movieclip aptly named "form."
Secondly, you have the send button. This will be the button
that activates the code that sends the form information to
the PHP file. At that point, Flash's job is done. It's then
up to the PHP script to make sure the email gets sent.
[ assign a var value for each text field ]

[ all fields
in a movieclip named form ]
This calls loadVariables through the form movieclip sending all variables saved in that movieclip to email.php using the POST method. Because all the text fields in form have variables associated with them, this effectively sends all information filled out in those fields to the email PHP page. From that PHP page, the sent information can be retrieved using each field's var name. One thing to be cautious of is that you need to make sure the movieclip you are using loadVariables with exists long enough for it to send its variables to the URL specified. Because this mailer has a thank you screen after sending an email, you'll need to wait until Flash does that before showing that screen and losing the form movieclip.
Steps in Scripting PHP
Now we can write that PHP script, email.php, that really
makes this happen. Luckily, it's not really all that
difficult to write. Maybe not as easy as the previous Flash
script, but not difficult nonetheless. The PHP all revolves
around one function; the
mail function. All you need to do is to grab the
information sent from Flash and pass it in to this mail
function in PHP to have that information sent to your email
of choice.
*Name and email here are assigned to a single variable, headers, because of how the mail function works...
mail(recipient, subject,
message, other headers);Putting it All Together
All that remains now is uploading your published swf
(with accompanying html) and PHP file to your server. Be
sure you keep the PHP file in the same directory as your swf
and html or your script may not be found when called from
Flash. If you don't want it to be in that same directory, be
sure you correctly reference the location of the PHP file in
the loadVariables command used in Flash. Once uploaded, play
your movie and send yourself a message! It'll be fun - and
it will also test to make sure this actually works ;) since,
if you didn't already know, you can't test from your own
computer's hard drive unless you have the proper
configurations and PHP installed (which, more than likely,
is not the case). It's ok though, since you don't need it on
your personal computer, just your server. And if its working
from there, then you should be in the clear.
|
Just a final word before we wrap up. What you've seen here is freshly baked content without added preservatives, artificial intelligence, ads, and algorithm-driven doodads. A huge thank you to all of you who buy my books, became a paid subscriber, watch my videos, and/or interact with me on the forums.
Your support keeps this site going! 😇

:: Copyright KIRUPA 2026 //--