Testing Your Forms


It is possible to send a form to an e-mail address if you don't have a CGI script running on your server through the use of a mailto (an e-mail link, covered in Lesson 3) for the form action, which should be used only to test your forms. This method has a number of flaws, including errors that occur as a result of the browser not being configured to send mail or not being able to connect with an e-mail program, and the absolute lack of security. You should always use dynamic pages or CGI scripts for processing forms.

Note

Although the mailto action gives you a way to initially test your form, it is not a substitute for testing your form with the corresponding server scripts. You should always be sure to thoroughly test pages in a live environment to be sure that your scripts are working as expected before making them available to visitors.


1.

In the training.html document, select the form by clicking <form#training> on the tag selector. In the Action field of the form on the Property inspector, type mailto: followed by your e-mail address, with no spaces after the colon.

You should remember to include the colon and no spaces. This is the same way you inserted manual e-mail links in Lesson 3.

2.

Choose POST from the Method menu and type text/plain into the Enctype text field on the Property inspector.

You have set the encode type to plain text; otherwise, the text sent will be encoded into an almost unreadable form.

The enctype defines how the data in the form is encoded. The text/plain value formats the information with each form element on a separate line. Using this value makes it easier to read the results in an e-mail. If you don't define an enctype value, browsers use a default value that formats the data. Because the default is the one that should be used in most circumstances, you will usually not need to specify an enctype. This example is an exception because you are sending the data in an e-mail to test the form.

Note

To add a subject line to your form, change the Action to this: mailto:YourEmailAddress?Subject=Title for Subject goes here. The ?Subject= defines the text that follows as the subject. You can uses spaces in the subject, but do not use any other special characters such as quote marks, apostrophes, periods, or slashes (other than the ?Subject= that separates the e-mail and the subject) because they will interfere with the HTML code. This might not work with every browser and should not be used in any way other than the testing of your form.

Remember that the mailto action does not work reliably in all browsers. Use it only for testing. If your browser is not configured to send e-mail, you can't test the form in this manner.

3.

Save the file and test it in the browser.

Depending on the preview browser, you might receive warning messages about sending e-mail. If you choose to do so, the form results should be sent to the e-mail address you specified.

4.

Use the tag selector to select the <form#training> tag. Delete the text in the Action text field and change the Method to GET. Save the file and test it in the browser.

This is another way to test your forms. Instead of the results being sent via e-mail, the browser will remain on the page with the form, and the results of the form are appended to the URL in the Address field on your browser window.

You can close this file.




Macromedia Dreamweaver 8(c) Training from the Source
Macromedia Dreamweaver 8: Training from the Source
ISBN: 0321336267
EAN: 2147483647
Year: 2006
Pages: 326

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net