Latest web development tutorials

ASP Form

Request.QueryString and Request.Form command is used to retrieve information from a form, such as user input.


Examples

Try - Example

Use method = "get" form
This example demonstrates how to use the Request.QueryString command to interact with the user.

Use method = "post" form
This example demonstrates how to use the Request.Form command to interact with the user.

Use the radio buttons Forms
This example demonstrates how to use the Request.Form command via radio buttons to interact with the user.


User input

Request object can be used to retrieve user information from the form.

HTML form instance

<form method="get" action="simpleform.asp">
First Name: <input type="text" name="fname"><br>
Last Name: <input type="text" name="lname"><br><br>
<input type="submit" value="Submit">
</form>

User input can be retrieved via Request.QueryString or Request.Form command.


Request.QueryString

Request.QueryString command is used to collect use method = "get" in the form of value.

From a form using the GET method of transmitting information to all users it is visible (appears in the browser address bar), and on the amount of information transmitted is limited.

If the user in the above HTML form input "Bill" and "Gates", sent to the server's URL will look like this:

http://www.w3cschool.cc/simpleform.asp?fname=Bill&lname=Gates

Suppose "simpleform.asp" file contains the following ASP script:

<body>
Welcome
<%
response.write(request.querystring("fname"))
response.write(" " & request.querystring("lname"))
%>
</body>

body part of the browser will display the document as follows:

Welcome Bill Gates


Request.Form

Request.Form command is used to collect use method = "post" in the form of value.

Using the POST method of transmitting information from the form is not visible to the user, and there is no limit on the amount of information to send.

If the user in the above HTML form input "Bill" and "Gates", sent to the server's URL will look like this:

http://www.w3cschool.cc/simpleform.asp

Suppose "simpleform.asp" file contains the following ASP script:

<body>
Welcome
<%
response.write(request.form("fname"))
response.write(" " & request.form("lname"))
%>
</body>

body part of the browser will display the document as follows:

Welcome Bill Gates


Forms Authentication

Whenever possible, as far as possible in the browser to validate user input (via client-side scripting). Browser validation is faster and reduces the server load.

If the user enters will be saved to the database, then you should consider using server-side validation. There is a good way to verify that the server-side form, that is, the (proven) form returns form page, rather than go to a different page. Users can then get an error message on the same page. Users find it easier to do wrong.