Your Ad Here

Contact Form


Requirements

  • Flash MX or higher.
  • PHP enabled server.

Preview

1. Start by creating a 300x300 document in Flash.

2. Select the Text Tool.

3. In the Property Inspector make sure the Text type is set to Static Text.

4. Click near the top left of the Stage and type "Name:".

5. Below that text click and type "E-mail:".

6. Below that text click and type "Comments:".

7. You should have something that looks like the following.

image 1

8. In the Property Inspector change the Text type to Input Text.

9. To the right of "Name:" draw an input text box that stretches across the rest of the stage.

10. In the Property Inspector click the Show border around text button and put "tName" for the Instance name.

11. To the right of "E-mail:" draw an input text box that stretches across the rest of the stage.

12. In the Property Inspector make sure the Show border around text button is selected and put "tEmail" for the Instance name.

13. In the Property Inspector change the Line type to Multiline

14. Beneath "Comments:" draw a rectangular input text box that covers the area underneath Comments.

15. In the Property Inspector make sure the Show border around text button is selected and put "tComments" for the Instance name.

16. You should have something that looks like the following.

image 2

17. Select the Rectangle Tool.

18. Draw a rectangle in the bottom right corner of the stage.

19. Select the Text Tool.

20. On top of the rectangle you just drew, click and type the word "Submit".

21. You should have something that looks like the following.

image 3

22. Select the Selection Tool.

23. Draw a box around the rectangle and "Submit" text to select them both.

24. Press F8 to convert your selection to a symbol.

25. Set the Name to "Submit Button" and set the Type to Button and press OK.

26. Click on the button you just created and in the Property Inspector put "bSubmit" for the Instance name.

27. Click on the first frame in the Timeline and press F9 to open the Actions Panel.

28. Insert the following ActionScript code into the Actions Panel.

bSubmit.onRelease = function()
{
        email();
}
function email()
{
        var sMessage = "Name: " + tName.text + "nE-mail: " + tEmail.text + "nComments: " + tComments.text;
        lvSend = new LoadVars();
        lvReply = new LoadVars();
        lvSend.msg = sMessage;
        lvSend.address = "email@email.com"; //Change this to your e-mail.
        tName.text = "Sending Message...";
        tEmail.text = "";
        tComments.text = "";
        lvReply.onLoad()
        {
                        tName.text = "Message Sent";
        }
        lvSend.sendAndLoad('mail.php', lvReply, 'POST');
}

29. Now open Notepad and paste the following code into it.

<?php
   $message  =  $_POST["msg"];
   $address  =  $_POST["address"];
   mail($address,"E-mail Form Message",$message);
?>

30. Choose File > Save as... and save the file as "mail.php" in the same folder as your swf.

31. Upload both files to your server to test.

Tutorial Files (Right click the link and choose save target as...)


 



Author's URL: Tutorial Scene
Thank you for voting.
Rate this Materials:
Bad 
1 2 3 4 5 Excellent
print this page subscribe to newsletter subscribe to rss

Internet & computing Flash is a vector-based moving graphics format created by Macromedia for the publication of animations on the World Wide Web. More Flash & Swish: Most Popular Materials | Fresh Materials | More Flash Tutorials at FlashPerfection.com

Add comments to "Contact Form"

Only registered users can write comment

Reader's comments
comments pHeR-d July 23, 2008 says:
Contact Form
you can also use this to change servers name which have name of "noname"

$message = $_POST;
$address = $_POST;
$from = "mail@xmail.com"; // From
$fromisim = "From Name"; // From name
$konu = "Subject";
$Header='MIME-Version: 1.0' . "n";
$Header.='Content-type: text/html; charset=utf-8' . "n";
$Header.='Content-Transfer-Encoding: 8bit'."n";
$Header.='To: '.$address."n";
$Header.='From: '.$fromisim.'<'.$from.">n";
$Header.='Return-Path: ' .$address."n"; // the address when e mail cannot send
$Header.='X-Mailer: mail service v1,5'."n";
$Header.='X-Priority: 1'."n";
mail($address,$konu,$message,$Header);
?>
comments alexaTLV February 21, 2007 says:
Contact Form
This is nice, clean and simple code but for some reason the only thing i get is "An error occurred and the message could not be sent." message.
Any ideas why it's not working?
My hosting allows php, so what's the problem?!?!