User Form Input with POST

Overview

The most basic form of interactivity on the Web is probably the HTML form. It is important to note that ASP does not replace forms, but rather enhances them, and makes them easier for you to implement and manage.

The HTML <FORM> tag specifies what method the form will use to convey information to the processing script. The POST method attribute indicates that information from the form will be passed to the processing script or program through a separate HTTP connection. The processing script or program can parse the information and do whatever task is required, and return output to the client browser.

Code Tour

This example demonstrates how to implement a simple form by using the HTML POST method attribute, as well as one key benefit of creating forms with ASP: the ability to combine the form and the actual processing code into the same file. This sample creates a small form with two text input boxes, one for the user's first name (fname) and one for his or her last name (lname). The Request.Forms collection is accessed to get the value of the fname and lname variables from the request, and the results are displayed at the bottom of the page.

The first time you run this script, no text will be displayed below the horizontal line. This is because no form information was available to pass to this script when it started, and ASP ignores searches of Request.Forms for information that does not exist. However, if you press the Submit button, the page is reloaded and the information you entered into the text boxes is available to the script.

Location

The VBScript and JScript versions of this script are available in the IIS samples directory, at ...\asp\interaction\Form_VBScript.asp and ...\asp\interaction\Form_JScript.asp.