Website Design and Programming - Introduction to Web Forms

There is practically no website without at least a form in one of its pages. Forms are useful to collect data from the website visitors and users. Once the user submits the form to the server, a form processing script must get the form data, validate that the user input matches the expected format for each field (e.g: email address field must be a string of text with the format of a valid email address) and process this information as desired. The script may save it into a database, send it by email or just do some processing with it and display the result. Validating the user input is essential to prevent malicious users from damaging your site. A form definition in html starts with the form tag and ends with the /form tag. This tag can have several attributes like method (GET or POST), and action (the url of the form processing script). If use the GET method, the form data is encoded in the action URL. This method is recommended when the form is a query form. With the POST method, the form data is to appear within a message body. This is the recommended method when the form will be used to update a database, or send email, or make any action other than just retrieve data. The form fields are used to collect the data. Generally a label is placed by each field, so the user knows what data to input. There are different kind of fields, among them: