Flashadvisor logo
:: Desktop Shortcut
:: Flash Help
Advices from Experts

 Submit Here! · Link to Us · Newsletter · Tell a Friend ·

      Add Tutorial |

 

Advertise here








 

Google

Search WWW   
FlashAdvisor.com

 Home > Tutorials  > Beginners

Custom PHP Email Form

Author: T Norman | Email


Advertisement

This will show you how to create a custom flash mail form in under 20 minutes! In order for this to work, your host must support PHP. Check with your website administrator if you are unsure. First let's start with Flash.





On the main stage, create 3 input text boxes and name them "name", "e mail","comments" and 1 dynamic textfield named "results". The "comments" text box is multi line and will be the body of the email, the others are single line. Align them on the stage how you want it to look. A suggestion is to keep the "results" textbox under or near your comments text box, as this will tell your visitor when the e mail is sent or if there is a problem. Create a submit button and give it these actions.......




on (release) {

// logical operator makes sure the textfield is not blank. IndexOf checks for "@" and "." characters in textfield

if (!email.length || email.indexOf("@") == -1 || email.indexOf(".") == -1) {

results = "Please check your e-mail address.";

} else if (!comments.length) {

results = "Please enter your comments.";

} else if (!name.length) {

results = "Please enter your name.";

} else {

loadVariablesNum ("http://yoursite.com/mailform.php", 0, "GET");

results = "Sending Data...";

}

}






Now for the PHP part of the form. Change the recipient field to your email address, and the subject line(YourAutomail) to whatever you like. Save this to a text file and upload it to your site as "mailform.php".



<?php

$TextVariable = '&results=';

$response = 'Data Sent. Thank You..';

echo $TextVariable;

echo $response;

/* recipients */

$recipient .= "" ;

/* subject */

$subject = "Your Automail";

/* message */

$message .= "Name: $name

Email: $email


Comments: $commentsn";

/* additional header pieces for errors, From cc's, bcc's, etc */

$headers .= "From: $name <$email>n";





/* and now mail it */

mail($recipient, $subject, $message, $headers);

?>



if you are using PHP 4+ User below Code

<?php
$recipient = "you@yoursite.com";

$vars = array("name","email","comments","results");

foreach($vars as $var)

$var = $_POST["var"];

$comments = str_replace("r","n",$comments);

$mail = "Contact from $name email $email
has left the following message: $comments ";

mail($recipient,"Your Automail", $comments, "From: $name");

print &results="Data Sent... Thank You.";

?>


That's all there is to it. Test it out!

More direct and effective than using the mailto method


*****Side Note*****
One thing that seems to confuse many people is the use of GET or POST. Brief explanation...



You can send OR receive variables with GET or POST. They essentially do the same task, it is the method they use to achieve the task that is different. When you send variables using GET, you're simply concatenating variable name/value pairs onto the URL itself. For example, if you wanted to use GET to send my name and email address to a script located on the register.php page, you'd specify the URL as ....



http://www.somedomain.com/register.php?name=NTD&email=webmaster@ntdesigns.net




The question mark preceding the variables tells the script and server that everything that follows compromise variables. Although GET is easier to use that POST, it wont work for every situation because it has a character limit of 1024 characters. When the variable data is sent(or received) using POST, the data is contained within the header of the HTTP request, which means you cannot see it being transferred. Because POST does not have a character limit, it provides for a more versatile and more secure way of sending variable data.


| 1 |

Rate This Tutorial :
We hope the information helped you. If you have any questions or comments, please don't hesitate to post them on the Forums section
Submit your Tutorial at Click Here
  

Home | About Us | Contact Us | Feedback | Advertise with us

Best viewed in 800x600 resolution with Internet Explorer.

Site Developed and Hosted by  ethicsolutions.com
All rights reserved with FlashAdvisor

Flash is a registered trademark of Adobe Systems, Inc.

1 user online