Modular Software - Home PicLan-IP - Home

Part 6: Web Form Processing, How to Get Input

Earlier, we mentioned that HTML web pages can include input fields and controls. HTML supports the following types of input fields: Each of these input "controls" provides a means of gathering data from the user and passing that data to the web server. The web server can then interpret the supplied parameters and perform whatever processing is required.

How Input is Passed to the Web Server

When a user is presented with an HTML form and submits the form to a web server, the web server received the incomming data in one of two manners. The two "methods" used by a web browser to submit data to a web server are called GET and POST. On the surface, these two method appear quite different, but the underlying data concepts are actually identical.

Field Names and Values

When data is sent to the web server, the data is sent as "pairs" of information. Each HTML form control has associated with it a name and a value. The name and value are both printable strings. It is possible to have a form with two controls that have the same name, but this is usually avoided. Both the name and value are case sensitive.

PicLan-IP processes inbound data with helper functions that are included in the active MV/Basic code that is included on the HTML page that the data is posted to. These functions allow your MV/Basic code to "read" the value of named form controls with a MV/Basic statement that looks like:

PL_GETVAR val FROM name ELSE ...
This statement looks like a Pick read statement, but is actually an extension to MV/Basic that the PicLan-IP web server supports. It is time to look at an example. This is an example of an HTML form:

The actual HTML source that is involved in creating this input filed is:

Name: <input type=text size=30 maxlength=256 name="NAME" value="George">
This example create a single input field with name=NAME and with an initial value=George. If the user submits this form, the web server can retrieve the value George that is associated with the input field named NAME. With PicLan-IP you would retrieve this form variable's value with the statement:

Supplying Initial Values

When a user encounters an input field, the initial value for a field is often supplied as a result of a previous page. In the above example, the initial value of the field named NAME was hard-coded to a value of George. A more common usage is to supply the initial value as the result of a MV/Basic calculation. In this case, the input field might be defined as:
Name: <input type=text size=30 maxlength=256 name="NAME" value="{NAME}">
This illustrates how PicLan-IP insertion points can be included anywhere within the HTML text, including embedded within HTML tags.

Other Types of Input Fields

Earlier, it was mentioned that there were other types of input fields available within HTML forms. In addition to single-line text fields, you can include multi-line text fields, check boxes, radio button (a radio button is like a check box but only one selection is active at a time), drop-down menus, push buttons, and clickable images. Each of these form controls set the value of a named form variable. Some controls like push buttons and clickable images also cause the contents of the page to be transmitted to the web server.

One last type of form field is the hidden input field. A hidden input field acts just like a text box except that it is not displayed. At first though, you may wonder why you would want a non-displaying input field. The answer is that this provides a mechanism whereby the web server can save information as a part of a form that will be returned the next time the form is transmitted back to the web server. Remember that the HTTP protocol is stateless. This means that the web server gets discrete events and has no real concept of a session with any particular user. Hidden input fields allow the web server to same information about a user, such as their account number, password, previous pages accessed (along with data), and similar as a part of the form. This way, the HTML form itself stores the "state" information about the user.

Differences Between GET and POST

Earlier, we mentioned two methods of requesting a page called GET and POST. GET and POST are actually two "methods" defined by HTTP version 1.0. GET is the default method of requesting a page. If the HTML page has form input fields, then the values of these fields will be included in the command line that is passed to the web server as in:
In this manner, GET allows you to pass data to the web server as a part of the resource name. POST supplies exactly the same data to the web server in exactly the same format, except that instead of being a part of the command line, the data is hidden in the HTTP header (which is not displayed but is available to the PicLan-IP web server).

Whether you should use GET or POST is up to you. There are some issues that you should consider. GET allows the user to "see" what is going on. In some cases, this is not a bad thing. In other cases, you may wish to hide your programs logic. GET also allows a page, along with supplied data, to be "bookmarked" (added to the browsers bookmark file). If you do not wish to let the user arbitrarily run a function, using POST makes this more difficult. An finally, there is a limit to the number of characters that browsers and web server support with GET (PicLan-IP does not actually have a hard limit here, but most web servers and all web browsers do). So if you are passing a large amount of data or if the data should be kept private, use POST instead of GET.

1 2 3 4 5 6 7 8 9
Modular Software - Home PicLan-IP - Home