ASP form
The Request.QueryString and Request.Form commands are used to retrieve information from a form, such as user input.
Try it - Example
Use method="get" form
This example demonstrates how to use the Request.QueryString command with the user to interact.
Form using method="post"
This example demonstrates how to use the Request.Form command to interact with the user.
Forms using radio buttons
This example demonstrates how to use the Request.Form command to interact with the user through radio buttons.
User Input
The Request object can be used to retrieve user information from a form.
HTML Form Example
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 through the Request.QueryString or Request.Form command.
Request.QueryString
The Request.QueryString command is used to collect values from a form using method="get".
Information transferred from a form using the GET method is visible to all users (appears in the browser's address bar), and there are limits on the amount of information sent.
If the user enters "Bill" and "Gates" in the above HTML form, the URL sent to the server will be similar to this:
Assume the "simpleform.asp" file contains the following ASP script:
Welcome
<%
response.write(request.querystring("fname"))
response.write(" " & request.querystring("lname"))
%>
< ;/body>
The browser will display the body part of the document as follows:
Request.Form
The Request.Form command is used to collect values from a form using method="post".
Information transferred from a form using the POST method is invisible to the user, and there is no limit on the amount of information sent.
If the user enters "Bill" and "Gates" in the above HTML form, the URL sent to the server will be similar to this:
Assume that the "simpleform.asp" file contains the following ASP script:
Welcome
<%
response.write(request.form( "fname"))
response.write(" " & request.form("lname"))
%>
</body>
The browser will Display the body part of the document as follows:
Form Validation
Whenever possible, try to Validation of user input on the browser (via client-side script). Browser validation is faster and reduces server load.
If user input will be saved to a database, then you should consider using server-side validation. A good way to validate a form on the server side is to pass the (validated) form back to the form page instead of going to a different page. Users can then get incorrect information on the same page. This makes it easier for users to find errors.