Inserting a Form - HTML

You insert a form into your document by placing form fields within <form> tags. The entire form or any of the tags can be formatted like any other element in your document, and can be placed within any element capable of holding other elements (paragraphs, tables, and so on).

The <font> tag has the following, minimum format:

<form action=“url_to_send_data” method=“get|post”>

The action attribute defines a URL where the data from the form should be sent to be “handled.” Although you can use just about any URL, the destination should be a script or other construct capable of correctly interpreting and doing something useful with the data.

Note: Form actions and form data handlers are covered in the section, Form scripts and script services, later in this chapter.

The second attribute, method, controls how the data is sent to the handler. The two valid values are get and post. Each value corresponds to the HTTP protocol of the same name.

The HTTP GET protocol attaches data to the actual URL text to pass the data to the target. You have probably noticed URLs that resemble the following:

The data appears after the question mark and is in name/value pairs. For example, the name id has the value of 45677, and the name data has the value of Taarna.

Note:In most cases, the name corresponds to field names from the form and may relate to variables in the data handler.
However, because the data is passed in the text of the URL, it is easy to implement—you can pass data by simply adding appropriate text to the URL used to call the data handler. However, GET is also inherently insecure. Never use GET to send confidential data to a handler, because the data is clearly visible in most user agents and can be easily sniffed by hackers.

The HTTP POST method passes data encoded in the HTTP data stream. As such, it is not typically visible to a user and is a more secure method to pass data, but can be harder to implement. Thankfully, HTML forms and most other Web technologies make passing data via POST a trivial task.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd Protection Status

HTML Topics