POST and GET Methods

Sep 25, 2007 15:17 GMT  ·  By

After you have met the basic concepts of HTML, you might want to discover HTML forms. As you already know, the form design is easy to accomplish by using WYSIWYG editors, which allow you to visually construct the form structure using drag and drop actions. But just the standalone form will not help you in receiving the feedback from your users, in a contact form for example. The form does not work by itself.

The HTML file where you put the form code will determine the display of the form only on the client side. After the client will fill in the form and hit the submit button, depending on the form action, a server side script should process the form in order for you to obtain the form data. Let's consider a simple form, where you request the name and email to your site visitors:

code
Name:

Email:
The input fields of type text have some default predefined values and names. When the site visitors hits the Submit button, the content of the form will be processed by a file executed on the server side and the data will be sent using method post. There are two methods to send form data: post and get, and many other options for selecting the form processor script. The form processor script could be of PHP or ASP type for example, depending on your web hosting account.

The script needed for the form processing could send the form data after processing to a datatabase, an email address or another HTML page. For example, a quiz form will usually have the content sent to a database, while a contact form data will go to an email address. The get method is less secure and not recommended to manipulate form data, because it includes the form content in the URL of the page. In this way, secret data, such as credit card accounts or email addresses will appear in the URL name before processing.

Another disadvantage is the limited size of the information that could be sent by using the get method. On the other side, the post method is more secure, because it separates the form content from the page URL and it has not the same limitations concerning the minimal data size that can be sent from a form. There are also situations when the get method is useful, such as when you want to send the data from a search web form. The modality of forms processing will influence the dynamic character of your website when user interaction appears. The form content validation, besides the processing actions, is also important for you in order to obtain the correct data from your site users.