Flash and PHP contact form actionscript Creating contact mail form in flash
About php and flash contact form
This is a contact form made in flash and php, it can be used on ‘contact us’ pages.
A flash file contains the form items and when the ’send’ button is pressed it sends the values to mailer.php, this mailer.php sends the email to the receiver.
Few of the benefits of using a flash form instead of a html contact form are:
better user interface
less junk messages (automated scripts cannot send emails through a flash form unless it is decompiled)
Usage details
Upload mailer.php and form.swf on your server in same directory.
In mailer.php you will have to replace ‘email@yourserver.com’ with your email address. Make sure this is an email hosted on that server where you are testing (most server requires this).
Preview
This is a preview of how the contact form looks, you try sending an email to see how form reacts, email will not be sent. It shows a warning if some of the fields are not filled.
<?php
/* —————————
php and flash contact form.
by www.MacromediaHelp.com
—————————
Note: most servers require that one of the emails (sender or receiver)
to be an email hosted by same server, so make sure your email
(on last line of this file) is one hosted on same server.
————————— */
// read the variables form the string, (this is not needed with some servers).
$subject = $_REQUEST["subject"];
$message = $_REQUEST["message"];
$sender = $_REQUEST["sender"];
// include sender IP in the message.
$full_message = $_SERVER['REMOTE_ADDR'] . “\n\n” . $message;
$message= $full_message;
// remove the backslashes that normally appears when entering ” or ‘
$message = stripslashes($message);
$subject = stripslashes($subject);
$sender = stripslashes($sender);
// add a prefix in the subject line so that you know the email was sent by online form
$subject = “Contact form test”. $subject;
// send the email, make sure you replace email@yourserver.com with your email address
if(isset($message) and isset($subject) and isset($sender)){
mail(”email@yourserver.com”, $subject, $message, “From: $sender”);
}?>
Contents of the FLA flash file (ActionScript)
stop();
send_btn.onRelease = function() {
my_vars = new LoadVars();
my_vars.sender = email_box.text;
my_vars.subject = subject_box.text;
my_vars.message = message_box.text;
if (my_vars.sender != “” and my_vars.subject != “” and my_vars.message != “”) {
my_vars.sendAndLoad(”mailer.php”, my_vars, “POST”);
gotoAndStop(2);
} else {
error_clip.gotoAndPlay(2);
}
my_vars.onLoad = function() {
gotoAndStop(3);
};
};
email_box.onSetFocus = subject_box.onSetFocus=message_box.onSetFocus=function () {
if (error_clip._currentframe != 1) {
error_clip.gotoAndPlay(6);
}
};


Discussion Area - Leave a Comment
You must be logged in to post a comment.