Processing password fields

Processing of a password field is very similar to processing a text box field. Normally, when we request the user to enter password, we use the set the method attribute to POST when constructing the form. This hides the password from appearing in the URL when the user submits the form. If you need help, review the discussion about the difference in processing of the GET and POST methods.

Before we process a form, we need to first create the form. The following code shows a simple form:

This is only an example so submit any arbitrary characters though up to 15. The input is not stored or validated!

To create the form shown above, use the following code:

<form method="post">
Username: <input type="text" name="Uname" size="15" /><br />
Password: <input type="password" name="passwd" size="15" />
<input type="submit" name="SubmitLoginInfo" value="Log In" />

We start with the <form> tag to indicate the beginning of the form. The <form> tag includes the attribute method that is set to POST. What that means is that we do not want the data submitted user to be added to the end of the URL. Remember the submitted form data will be sent automatically to the file that contains the form. To send the form data to a different file, use the action attribute. For simplicity, we process the form in the same document that contains the form.

This form has two input boxes. The box collects the username and the second password. Note how the type attribute is set to different values: text for textual input and password password input. The main difference between these two fields is that the text field shows on the screen exactly what characters are typed; however, the password field replaces each typed character with a bullet or asteriskcharacter.

Lastly, to submit the form, we create a submit button named "SubmitLoginInfo." We will use this name to determine whether or not the form has been submitted. Finally, we end our form with </form>.

To process the form, we could use the following code:

if request.form ("SubmitLoginInfo") <> "" then
response.write "Username you submitted: " & request.form("Uname")
response.write "<br>Password you submitted: " & request.form("passwd")
end if

The IF condition checks if "SubmitLoginInfo" is not empty. If it is not empty, we know the form has been submitted. However, if it is empty, then, the form has not been submitted. If the form has been submitted, we display to the user what the user submitted. Notice how the text box, password box, and the submit button all are processed with request.Form().