Tutorial 13: Giving Form to Forms - HTML with Style | 19
Tutorial 13: Giving Form to Forms
Encodings and methods: A recap
The last two sections may have confused you a bit, so here's a summary:
There are two methods for submitting forms, and two types of encoding.
One method is GET. When you use GET, the encoding must be (deep breath) application/x-www-form-urlencoded (exhale). This method is nice, clean and simple, and not too much fuss. It has several advantages: First, since the location of the results can be referred to using only a URL, you can save this URL and get those results again simply by visiting this URL, or link to them directly using the A element. This is great for lazy people like me. This only makes sense if the program that processes the data doesn't actually do anything, just processes your input and gives a result. An example of this would be the proverbial telephone directory lookup. Nothing actually changes when you look up a name in the directory; you just get some information back. This is an excellent example of when the GET method is appropriate. You can have a form that allows a user to search the directory using any name they want, but you can also, for instance, link to a specific entry in the directory by using the URL with the form data appended to it in the HREF attribute of an anchor, or you can bookmark the results from a search so you can quickly check if someone specific has changed his number.
The alternative is POST. The results of submitting a form from this method cannot be linked to, but this can be an advantage. If, for instance, a form orders something from an online catalogue, you definitely don't want to be able to create a link that orders an item for the same person while charging the same credit card every time someone follows the link. Hold on... (demonic laughter in the background as author goes off to find his professor's credit card number and the Pizza Hut Web site). Ahem. Only kidding. Thus, the POST method is useful for forms that actually do something once they are submitted. Other advantages are that the form data can be encrypted for security, that you can send files along with the data, and that you can use a mailto: URL to send the data via e-mail.
In the end, the method and encoding you use depends on the processing program. If you write this yourself, then you can pick the right one, but if you're using someone else's program, you'll have to check with the documentation to see what method or encoding it requires.
Produced by Stephanos Piperoglou
URL: https://www.webreference.com/html/tutorial13/6.html
Created: May 28, 1998
Revised: February 25, 1999