Search Tutorials
Part II - Setting up the server scripts Note: I have included three options in this
tutorial - PHP, Perl, and ASP - You only need to use one. This mainly
depends on what type of server that you are using, and what is available on
that server. For Unix/Apache based servers, the Perl and PHP ones will
work - with Perl being a little more universal. For win NT/2000 servers
the ASP and Perl scripts will work - some modifications will have to be made
to the Perl script however. To find out what type of server you are
using and what scripting languages you have available for use, either view the
documentation provided by your host, or call your server's tech support.
One thing to remember is that these script examples were written as educational examples, with simplicity and ease of use in mind. They all work and can be immediately used, but extra security precautions should be taken if you are planning to use these scripts extensively on a public website, and have any reason to believe that someone would take advantage of them. Option 1 - Setting up the PHP Script - to send mail with PHPThe PHP option remains my favorite, it is easier to set up then the rest and PHP in general is easier to learn and understand for this type of application (Opinion). Your server has to have either PHP 3 or 4 installed to be able to use the following. The Code is listed below - each line of the code is then discussed. Line numbers should not be included in the Actual script. This script is also included with the download. After you have made any changes, upload the script to the same directory that you will be running the Flash movie that contains the Mail form. If you have the script in a different directory you will have to change the path in the loadvariables command (Send Mail Button)). Note: The $ symbol in PHP indicates a scaler variable. Note: The User Entered variables in this case / example
are - FirstName, Email, Company, ToComments, HearAbout - These values are from
the flash movie. No special parsing is required in PHP if it receives these
variables then they are already set inside the script. You may also want to
add the stripslashes function in this script if you don't want slashes to be
added to your output. An example of how to do this would be: $ToComments =
stripslashes($ToComments);
1) <? 2) $ToEmail = "jeff@snowvids.com"; 3) $ToName = "Jeff"; 4) $ToSubject = "Example Mail from SendMail Tutorial"; 5) $EmailBody = "Sent By: $FirstName\nSenders Email: $Email\nSenders Company: $Company\n\n Message Sent:\n$ToComments\n\nSender Heard About Site From: $HearAbout\n"; 6) $EmailFooter="\nThis message was sent by: $FirstName from $REMOTE_ADDR If you feel that you recieved this e-mail by accident please contact us at www.yourSite.com"; 7) $Message = $EmailBody.$EmailFooter; 8) mail($ToName." <".$ToEmail.">",$ToSubject, $Message, "From: ".$FirstName." <".$Email.">"); 9) Print "_root.Mail.EmailStatus=Complete - Your mail has been sent"; 10) ?> Open up the attached script called snowMailPHP.php and follow along - you can use any text editor to make any changes. Line 1: This just indicates the start of a php script. In some cases it can be <?php or <?php3. Line 2: This is one of the most important lines - this contains the e-mail address of the person that you want the message sent to. In most cases this will be your own e-mail address. I left it as my own for now - Be sure to change this to Your e-mail address. Line 3: This Line contains the Name of the person that you are sending this E-mail to. In most cases you will hard code that into the script here, as shown. You can also set this variable as a hidden variable in the Flash movie. When you use the 'Post command' in conjunction with this script, the hidden variable will be sent along with the other variable values. Line 4: This Line sets the Subject line of the e-mail that you are sending. Line 5: This line combines the variables that were sent to the script by the 'Post command' when you used load variables from the Flash movie. This is where you can format the look of your e-mail. Line 6: This adds some additional information to the bottom of the e-mail that you are sending. You can add any extra info you want here. Make sure to remember that everything has to be enclosed with " symbols and a ; symbol has to end the line. Also note that the \n combo adds a return/new line to your e-mail. Line 7: This just combines the variables $EmailBody and $EmailFooter into one variable $Message. Line 8: This line is what actually sends the E-mail. The php Function Mail is what does the job. By enclosing the E-mail tags within <> symbols it creates something like a mailto function. That way the person can respond to the e-mail directly. Line 9: This prints a message back to the flash movie. In this case it sets the variable EmailStatus contained in the movie clip instance of Mail to a value of " Complete - Your mail has been sent". Line 10: This just signifies the end of the PHP code. Well those are the basic's of what you need to know to send mail from a form in Flash with PHP. I hope that wasn't too confusing.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|