PHP Flash Form-Mail Tutorial

I have experienced the pain of trying to find out HOW TO MAKE A MAILFORM in flash so once i figured it

out I thought I’d share it with you all.

1). Open a new file and have one layer with two keyframes

2). Put a stop() action in each of them buy *right-clicking on the keyframe, selecting actions and

choosing ‘stop()’ from the basic actions list*

3). Now drag and drop all the text sections that you want into the first keyframe. Make sure that the

text fields that you expect the user to fill in are changed to input text found in the

properties box.

4). Create 2 buttons. Call one send and the other clear.

5). Still in keyframe 1 put the variable in each ‘input text’ selection. NOT THE INSTANCE NAME!! If it

is a name that you are getting, make it easy and type ‘name’ (without the quotes) in the VARIABLE box

in the property section. (you might have name/phone/email/comment)

6). Click on the ‘clear’ button and put the following in the ‘actions’ section


on (release) {
name = "";
phone ="";
email ="";
comment ="";
} 

This tells the variables to clear if the button is pressed.

7). Then click on the ‘send’ button and put the following in the code:


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

This will make sure all fields are filled out before the user can click send. If you dont need certain

areas filled out then just remove it from the code. Erase from the ‘or’ to the “” . Then you’ll notice

that it tells it to send the information to ‘form.php’. We will make that now.

8).Open notepad and enter


<?PHP
$to = "[email protected]";
$msg = "$name

";
$msg .= "$phone

"; 
$msg .= "$email

"; 
$msg .= "$comment

"; 
mail($to, $subject, $msg, "From: My web site
Reply-To: $email
");
?> 

Replace the email with your own and then add all of the variables you’ve used. When you use multiple

variables you have to use “.=” as shown above in the code. The
is just like a br in html.

It starts a new line. Make sure to have the ; as they show there is more code to come.

9).Now save this file as form.php (You’ll have to type in the extension or it will just save as txt.

10). Go to keyframe 2 and enter whatever confirmation text you want the user to see upon submiting his request.

  1. Upload the .swf and the .php to your server and there you are…a mailing form ready for your

visitors.

Happy Mailing All.

:love:

Make sure you use the $_POST[]; array to catch the variables. That script won’t work on some hosts if they have global variables turned off. Check out my post in the BEST oF KIRUPA section and read Senocular’s posts to see what I mean.

**You beat me to it, I had a tutorial for this coming out too. :stuck_out_tongue:

i followed the tutorial, but it wont mail to my address?
i tried to follow you jubba on the php thing but alas in your tutorials for flash/php i didnt see the to e-mail address?

in this tutorial

<?PHP
$to = “me@mydomain”;
$msg = "$name

";
$msg .= "$email

";
$msg .= "$company

";
$msg .= "$comment

";
mail($to, $subject, $msg, "From: my domain
Reply-To: $email
");
?>

that’s what i have in my php file? am i missin somthn’. and i do think it has to do w/ the $_POST[] command.

hope this makes sense to help me complete this wonderful tutorial!
thanx
jayemsee!
++++++++++++++++
im enclosing my version of it, it’s too big but i wanted to get it to work first before refining.!

i tried it again? this time w/ $_POST. but i still dont think i know what im doin?
please when you can try to help out on the sending PHP part?
thanx again
jayemsee
www.jayemsee.com

check out this post as well, it might help. I included the source files at the bottom of the posts too.

http://www.kirupaforum.com/forums/showthread.php?s=&threadid=17604

its the second post.

jubba … i can’t make your file work. i d/l’d the zip file and put the contents on my server. it doesn’t do anything when i press the send button. I guess i will go read through all the posts on this subject and see if i can figure it out.

i already have a php mail form on my server in html but it would be nice to be able to incorporate one into my flash movie.

so i would make this my form.php that flash loads as a variable?

<?

// Recieving and Creating Variables…
$Name = $_POST[‘name’];
$Email = $_POST[‘email’];
$Message = $_POST[‘message’];
$Subject = “Test E-mail Tutorial”;
$Header = “From: $Name <$Email>”;

//Performing Mail script…
mail($Email, $Subject, $Message, $Header);

?>

my questions are? where is the area i put in my e-mail address so it comes to me?
and lets say i have name, e-mail, company, comment???
i tried you example but it dosent work? unless im an absolute php-tard, which probobally isnt that far off anyway.

i have the send button in flash calling for


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

thanx

i made it work
http://www.aaronsleeper.com/num2/PHPMailTest.fla
http://www.aaronsleeper.com/num2/form.php

it sends it to me … so you can change the variables as needed

thanks very much for your help everyone.

i’m going to go animate it now and make it all purdy for my site =)


jayemsee


$to = "PUT YOUR EMAIL BETWEEN THESE QUOTES";
$msg = "$name

";
$msg .= "$email

"; 
$msg .= "$company

"; 
$msg .= "$comment

"; 
mail($to, $subject, $msg, "From: my domain
Reply-To: $email
");
?>

=)

hmmmph

it was working … i put it in the fla for my site and now it’s not working … what’s up with that

http://www.aaronsleeper.com/site.fla
http://www.aaronsleeper.com/form.php

the mail form is in _root.window.content.mailform

i haven’t done any animation and hardly any editing to the original script … so i’m not sure what’s wrong :frowning:

Im lost now man.

See if you make a tutorial make sure you go over it and make it work yourself and show an example.

Please re do it or somthing

your clear fields dont work either FYI, stupid php! i mean i animated it and everything but, it calls the .php but wont send?
o well well see
jayemsee

OK here is my source just that now i cant upload to my site the ****!!! hosting out but here si the source check it out to see if the code look aight

jayemsee:
they just stopped working … weird … i’ve been able to clear the fields this whole time … it’s simple enough. i’m not sure why they’re not working.

now i’m just having a lot of trouble. this is frustrating

i switched PHP scripts … i’m now using a piece of the script that runs the HTML version of my mailer on my site it is as follows:


<?
$msg = "E-mail sent from www.aaronsleeper.com

";

$msg .= "From Name:    ".$_POST["name"]."
";
$msg .= "From E-Mail:  ".$_POST["email"]."
";
$msg .= "Telephone:    ".$_POST["phone"]."

";
$msg .= "Subject:	   ".$_POST["subject"]."

";
$msg .= "Message:      ".$_POST["message"]."

";

$to = "[email protected]";
$subject = "aaronsleeper.com - ".$_POST["subject"];

$mailheaders .= "Reply-To: ".$_POST["email"]."

";

$result = mail($to, $subject, $msg, $mailheaders);
?> 

BullDog_Flash:
I looked at your files and everything looks right according to the tutorial. You should make sure though that the server to which you’re uploading your files supports PHP. some servers don’t

Jubba:
Lostinbeta:
Ilyalmasse:
Senocular:
Sbeener:
Anyone!!!:
please help us figure these out

my files are located at:
http://www.aaronsleeper.com/form.php
http://www.aaronsleeper.com/site.fla

thanks =)

alright now i figured out why my clear button wasn’t working

i had to specify the path to the variables from the root so in the part of the script that tells the fields to = “”; i had to put the path in front of it _root.window.content.mailform.fieldName = “” ;

so i then applied the same principle elsewhere in the mailform and it works … it sends mail BUT it doesn’t seem to send the variables as specified in the PHP … it just sends the text specified there and sends the mail … but nothing the user types … goes with it :frowning:

help
files are still in the same location as the previous post

Shuga yes my hosting does support PHP but its not wokring yet

you have to define the $_POST[];

I don’t think you can just do

$_POST['email];

you have to do


$email = $_POST['email'];

and then put $email whereever you need that varable…

oh, and bulldog. Her tutorial works for her. When people begin to modify things start to not work.

i dont even have any of those issues, lol mine just plain and simply wont send! not a thing! anyway-
i tried lookin into .asp, and lookin up tutorials on PHP but they just give the dynamics, and other email php scripts, dont use this
$_POST command were all tryin to figure out?
anyway i’ll keep checkin back, im pretty sure some one on this site uses php to communicate to php from flash! if so PLEASE HELP!
thanx jayemsee

Jubba could you tell me some hosting with P{HP support so i can try it all out or somone telkl me please

Ok, I’m going to look thru your posts now and try to help. Bulldog, the only free host that supports PHP is http://www.tripod.lycos.co.uk/

i’ll post back in a few minutes because I have some time now. Waiting for a response from a client.