Request object is used to retrieve information from a form. In the
HTML
application, a very useful form to request information from the user.
Generally this information is used in the email application, guest
books, and other forms.
Processing Input Form
HTML document containing the form will not have the tag like the following :
<FORM METHOD = "GET|POST" ACTION = "Nama_file.asp">
FORM
tag above has two attributes, which are used METHOD to return the form
to the value of programs and files that contain Nama_file.asp ACTION.
Nama_file.asp file which will process a given input values
on a
form. Method is available in two ways, namely the GET method returns a
value in the form of a query string and POST method that returns value
in the standard form.
The use of ASP in the process form is divided into three ways, among others:
1. Form of ordinary HTML files are processed by the ASP file.
2. Form of ASP files are processed by the ASP file.
3. Form of an ASP file that is processed by the ASP file itself. this way used to verify the value of the input form.
To make the process to be done by using the input form
Request
object. The input form will be accommodated in two ways, namely by a
collection of QueryString and Form collections. Differences in the use
of both the collection method depends on the attributes of the Form tag.
Collection Query String
Request.QueryString
command is used to retrieve the value from a form that use METHOD =
"GET", which will form the information transmitted seen by the user or
browser looks at exactly that written on the address
bar behind the URL address and the information transmitted is limited. as an example try the following program :
<HTML>
<HEAD>
<TITLE> .::Penggunaan Koleksi QueryString::. </TITLE>
</HEAD>
<BODY>
<PRE>
<FORM NAME="myForm" METHOD="GET" ACTION="proses.asp">
Nama : <INPUT TYPE="text" NAME="nama"> <BR>
Tempat/Tanggal Lahir : <INPUT TYPE="text" NAME="tgllahir"> <BR>
Program Pilihan : <INPUT TYPE="text" NAME="program"> <BR>
<INPUT TYPE="hidden" NAME="status" VALUE="baru">
<INPUT TYPE="submit" NAME="btsubmit" VALUE="
TYPE="reset">
</PRE>
</FORM>
</BODY>
</HTML>
Save the above file with the name of the program or programs
6_1.asp 6_1.htm. if run in the browser, it will look like the following :
In
the program above 6.1, which is used in the FORM ACTION is a file
proses.asp which will process the input values given in an form.
Proses.asp This file will take data entered on file program6_1.asp. The
captured data will be incorporated into the collection QueryString by :
<%=
Request.QueryString("nama_variabel") %>
variable_name is the name of the form component that holds data to be retrieved.
Name component is indicated by the NAME attribute on the form component. example
program6_1.asp the example above, the data is the component that holds the name
<INPUT Type="text"> given attribute NAME = "name". Then to take the name
do the following:
<%= Request.QueryString("nama") %>
To complete the program 6_1.asp above, the following are the contents of a file
proses.asp:
<HTML>
<HEAD>
<TITLE> .::Penggunaan Koleksi QueryString::. </TITLE>
</HEAD>
<BODY>
<PRE>
Selamat datang <%= Request.QueryString("nama") %>
Tempat/Tanggal Lahir : <%= Request.QueryString("tgllahir") %>
Program Pilihan Anda : <%= Request.QueryString("program") %><BR>
<%
If Request.QueryString("status") = "baru" then
Response.write "Ini kunjungan pertama Anda"
End if
%>
</PRE>
</FORM>
</BODY>
</HTML>
Run in the browser program file 6_1.asp, then fill out the form and click the button
OK. The result is as follows:
In the note the browser address bar, the string will be written like this:
http://localhost/PraktikumASP/proses.asp?nama=Faishal+Hafidz&tgllahir=ba
ndung% 2F12-8-1985 & program = web + master & status = new & btsubmit = + OK + + + + + + +
Existing
string after the question mark (?) It is called with a query string.
This method has drawbacks. When you create a form that has a fair amount
of stuffing, then writing the query string in the back will be a long
URL address, there are some certain browsers that have a limited number
of characters writing URL address. This can result in the loss of values the query string. to avoid this, you should use Form collection.