Flash and PHP – Form Submission – Send Email Via Flash and PHP

by Hiroshi on October 20, 2008

in Adobe Flash, email, Flash PHP

Sending email via flash can be a bit tricky. Well! Not much tricky anymore if you follow these simple instructions and download example file. Create a movie clip, name it form and copy this ActionScript over that.

onClipEvent (data)

Whole form elements and submit button must be inside that movie clip.
Create input text fields and name them in field named as var.
Create a dynamic text field for error message.

Suppose you have created fields named as name, email, comments and error dynamic text field named as txt then at submit button place following action script.

on (release)
    if (name == "")
        txt = "Name Missing";
    else if (email == "")
        txt = "Email Missing";
    else if (comments == "")
        txt = "Comments Missing";

In the same movie clip at second frame place following actionscript.


We are posting variables from flash to PHP script page to send email. Now remember we placed following actionscript over main movie containing form.

onClipEvent (data)

Submit button will check whether fields are empty or not. if not it will post variables to PHP page and email will be sent.

You can define tabindex for fields too by adding following script at first frame where form fields are located.

name.tabIndex = 1;
email.tabIndex = 2;
comments.tabIndex = 3;
submit.tabIndex = 4;

Rough and shortest PHP email script is given here which you will put in the email PHP page located in the same directory where this movie is present with page calling it.

$myfrom = $email;
$myemail = "email@server.com";
// place the target email address above
$subject= "Message From website";
$message = "
Name: $name
comments : \n $comments
$from = "From: $myfrom\r\n";
mail($myemail, $subject, $message, $from);

Validating Flash Forms

Validating Flash forms with Dreamweaver and the JavaScript Integration Kit

Following is the downloadable file containing three examples regarding flash and php email sending and flash form validation.

Download PHP Flash Email With Validation Examples

Related Posts

Previous post:

Next post: