Tutorial
In ASP, you can invoke the program from VBScript and other means.
Instance:
-
-
Forms using Method= "get"
-
-
How to use the Request.QueryString command to interact with the user.
-
-
<%dim fnamefname=Request.QueryString("fname")If fname<>"" Then Response.Write("Hello " & fname & "!<br />") Response.Write("How are you today?")End If%> </body >
-
-
Forms using Method= "post"
-
-
How to use the Request.Form command to interact with the user.
-
-
<%dim fnamefname=Request.Form("fname")If fname<>"" Then Response.Write("Hello " & fname & "!<br />") Response.Write("How are you today?")End If%> </body >
-
-
Forms that use radio buttons
-
-
How to use Request.Form to interact with the user through radio buttons.
-
-
<%dim carscars=request.form ("Cars")%> < Body><form action= "/example/aspe/demo_aspe_radiob.asp" method= "POST" ><p>please Select your favorite Car:</p><input type= "Radio" name= "Cars" <%if cars= "Volvo" Then Response.Write (" Checked ")%>
value=" Volvo ">VOLVO</INPUT><BR/><input type=" Radio "name=" Cars "<%if cars= "Saab" Then Response.Write ("checked")%>
value= "Saab" >saab</input><br /><input type= "Radio" name= "Cars" <%if cars= "BMW" Then Response.Write ("checked")%>
value= "BMW" >bmw</input><br/><br/><input type= "Submit" value= "Submit"/></ Form><%if cars<> "" Then Response.Write ("<p>your favorite car is:" & Cars &A mp "</p>") end If%>
</body>
User input
The request object can be used to retrieve user information from forms.
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>
The information entered by the user can be retrieved in two ways: Request.QueryString or Request.Form.
Request.QueryString
The Request.QueryString command is used to collect values in a form by method= "get". The information that is transferred from the form using the Get method is visible to all users (appearing in the browser's address bar), and there is also a limit to the amount of information sent.
If a user enters "Bill" and "Gates" in the form instance above, send to the URL of the server.
Suppose the ASP file "Simpleform.asp" contains the following code:
<body>welcome<%response.write (Request.QueryString ("FName")) Response.Write ("" & Request.QueryString ( "LName")%></body>
The browser will display the following:
Welcome Bill Gates
Request.Form
The Request.Form command is used to collect values from a form by using the "post" method. The information that is transferred from the form using the Post method is not visible to the user, and there is no limit to the amount of information sent.
If a user enters "Bill" and "Gates" in the form instance above, send to the URL of the server.
Suppose the ASP file "Simpleform.asp" contains the following code:
<body>welcome<%response.write (Request.Form ("FName")) Response.Write ("" & Request.Form ("lname"))%> </body>
The browser will display the following:
Welcome Bill Gates
Form validation
Whenever possible, the data entered by the user should be validated (through the client's script). The browser-side verification is faster and can reduce the load on the server.
If the user data is entered into the database, then you should consider using server-side validation. A good way to validate a form on the server side is to conveys the (validated) table back to the (POST) Form page instead of going to a different page. The user can then get the error message on the same page. By doing so, users are more likely to find errors.