Flash CS3 - email contact form

Hi,
I’m using Flash CS3 with AS2 and have been trying to set up a basic contact form and nothing seems to work…plse help anyone.

I used this…http://www.kirupa.com/developer/actionscript/flash_php_email.htm

to create the AS code for the send button for my form

  • the php code as well from this Kirupa link.

I’m being hosted by Godaddy with the linux server with the email being sent to…
info@ciudaduna.com … which in turn is forwarded to ciudad_una_limited@yahoo.co.uk

When I fill out the form and submit - nothing is recieved in my inbox.
Having tested the forwarding from Godaddy to yahoo - does work!

Plse can anyone help with simply setting up a basic flash email form? I’ve been trying lots of different methods for the last 2 weeks including Godaddy’s own script & nothing seems to work…

???

Hey the13chapters, here’s what I did:

first, you need to create a movieclip with three input-textfields.
For the first, fill in ‘name’ in the Var: field.
The second: ‘email’.
And the third: ‘message’.
Maybe you want to put some static text next to the fields, such as ‘your name:’, ‘your email:’ and ‘your message:’.
Give the movieclip the instance-name ‘form’.

Then you need to create a send-button. This can just be a movieclip with the word ‘send’ and some background. Give it the instance name ‘mSend’. Add this code in an actionscriptlayer on a keyframe, on the same frame where the send-button keyframe is:


mSend.onRelease = function():Void {
    // send variables in form movieclip (the textfields)
    // to email PHP page which will send the mail
    form.loadVariables("email.php", "POST");
};

Then you need to upload this php-script to your server, in the same directory as your .swf, and name it email.php:


<?php
/***************************************************\
 * PHP 4.1.0+ version of email script. For more
 * information on the mail() function for PHP, see
 * http://www.php.net/manual/en/function.mail.php
\***************************************************/


// First, set up some variables to serve you in
// getting an email.  This includes the email this is
// sent to (yours) and what the subject of this email
// should be.  It's a good idea to choose your own
// subject instead of allowing the user to.  This will
// help prevent spam filters from snatching this email
// out from under your nose when something unusual is put.

$sendTo = "your@email.com";
$subject = "your subject";

// variables are sent to this PHP page through
// the POST method.  $_POST is a global associative array
// of variables passed through this method.  From that, we
// can get the values sent to this page from Flash and
// assign them to appropriate variables which can be used
// in the PHP mail() function.


// header information not including sendTo and Subject
// these all go in one variable.  First, include From:
$headers = "From: " . $_POST["firstName"] ." ". $_POST["lastname"] . "<" . $_POST["email"] .">
";
// next include a replyto
$headers .= "Reply-To: " . $_POST["email"] . "
";
// often email servers won't allow emails to be sent to
// domains other than their own.  The return path here will
// often lift that restriction so, for instance, you could send
// email to a hotmail account. (hosting provider settings may vary)
// technically bounced email is supposed to go to the return-path email
$headers .= "Return-path: " . $_POST["email"];

// now we can add the content of the message to a body variable
$message = $_POST["message"];


// once the variables have been defined, they can be included
// in the mail function call which will send you an email
mail($sendTo, $subject, $message, $headers);

?>

Change the $sendTo = "your@email.com" to your own email adress and $subject = “your subject” to the email-subject you want.

And you’re done!

0L4F,
Thanks for that I will try it and let you know

many thanks

0L4F,

Does this only work with a Movie Clip or can one use normal buttons as well? when I change it to a button it stops working…???

hey the13chapters,

to be honest, I haven’t used buttons for a long time now, as I see no advantage over the use of movieclips. But the code should work on buttons too… Are you sure its also called mSend?

You can always try to do it AS1 style, and put this code on the button itself (select the button and bring up the Actions panel (F9)):


on (release) {
    // send variables in form movieclip (the textfields)
    // to email PHP page which will send the mail
    form.loadVariables("email.php", "POST");
}

…let me know if this works for you!

Cheers,

Yep tried that already - I think because I’m using AS2 - that’s why its not working.
I’ll just play around with it to try to get it to work…

many thanks