Request object,
A request is a command to read data from the address bar, of from a form.
- Request.QueryString
- Reads the info that is send through GET. There is a limitation of 1024 bytes. With this method we can read info after the URL.
- Request.Form
- Reads the info that is send through POST.
- Request.ServerVariables
- parameters, typical for the server can be requested here.
- Request.Cookies
- they can be added to a variable.
With Request.Form and Request.QueryString you use the name of the fields to get the values.
Request.QueryString
With this command the data comes with the URL, after the name of the requested page.
The user can see this data, also those of hidden fields.
variable_everything=REQUEST.QUERYSTRING
variable_everything=REQUEST.QUERYSTRING("fieldname")It is possible to add more values to 1 field. The data is then send like this: fieldname=value1,value2
You can check the number of values with the following command.
number=request.querystring("fieldname").count
Request.Form
Form is used when the data may not be shown in the address bar or the data is longer then 1024 bytes.
REQUEST.FORM("fieldname")
ormfieldname="fieldname")
REQUEST.FORM(mfieldname)Example:
<% @language=vbscript %> <HTML> <HEAD><TITLE>Example (req_form.asp)</TITLE></HEAD> <BODY> <% if request.form("name1")=" " or request.form("address1")=" " then response.write("<form method=post action=req_form.asp>") response.write("<table>") response.write("<tr><td>Name</td>") response.write("<td><input type text name=name1>") response.write("</td></tr><tr><td>Address</td>") response.write("<td><input type text name=address1>") response.write("</td></tr><tr><td>City</td>") response.write("<td><input type text name=city1>") response.write("</td></tr></table&tg;") response.write("<input typr=submit>") response.write("</form>") else response.write("<h1>Your entry:</h1>") mname1=request.form("name1") maddress1=request.form("address1") mcity1=request.form("city1") response.write("name: "& mname1) response.write("<br>address: "& maddress1) response.write("<br>City: "& mcity1) end if %> </BODY> </HTML>Request.ServerVariables
The server can get more information from your browser then just the request for a HTTP-page. IP-address, port, ... can also be requested.
The script below request all servervariables.
Example:
<% @language=vbscript %> <HTML> <HEAD><TITLE>Example server variables</TITLE></HEAD> <BODY> <% sDim varitem for each caritm in request.servervariables if request.servervariables(varitem)=" " then response.write("<tr><td>"& varitem) response.write("<td> ") else response.write("<tr><td>"& varitem) response.write("<td>"& request.servervariables(varitem) &"</tr>") end if next %> </BODY> </HTML>If you only want the ip address:
Request.Servervariables("remote_waddr")