One of the requirements of web usage is when we want to take input from the user, such as name, age, and email address. An example is the Guestbook (Guestbook). Retrieval of data from the user form fields are usually in the form called Form. Using ASP, it is known what data is sent by the user to us through our web page. These data can then be processed according to the needs as will be discussed below.
Data Delivery Through Web Pages
Sending data through the web page can be divided into two, namely:
- Data delivery through querystring
Sending data through the QueryString done by write query string variables with data at the time calling web page. Examples include the following: http://www.agus.com/gallery.asp?Start=20
- Delivery Data Through Form
Sending data via the form is done with our first create a form, set the form data processing web pages, and then create a button of type submit to send the form data.
Sending data via the form can be done by two methods, namely Get and Post method. The syntax is as follows:
Method Get: <FORM Action="responder.asp" Method="Get">
Method Post: <FORM Action="responder.asp" Method="Post">
Responder.asp is the file name of the form data processing. if the name file processing form data is not set, then the file that contains the form is exactly regarded as a form of data-processing file. If we send data using Get method, then the data form will be sent through the URL, while the Post method, the form data is sent via HTTP headers.
Data Collection Through Web Pages
Data retrieval via a web page can be divided into two, namely:
- Data Collection Sent Through URL
The data is sent using the QueryString or Form Get method will be sent through the URL. To retrieve the data sent through the URL, we use the object Request.QueryString with syntax like the following: Request.QueryString ("name input")
- Data retrieval Sent Through HTTP Headers
Form data is sent using the Post method will sent through the http headers. To retrieve the data sent via http headers, we use the Request.Form object syntax is as follows: Request.Form ("name input")
example:
For example, we have a web page to request input from Shipping and Receiving Data Through Web Pages
user as follows:
<HTML><HEAD> <TITLE>Please send us your feedback</TITLE>
</HEAD>
<BODY bgColor="lightgrey"> <H2>Feedback</H2>
<FORM Action="fbresponder.asp" Method="Get"> <table border="0">
<tr> <td><font face="Verdana" size="2">Name</font></td>
<td><INPUT Type="text" Name="Nam"></td>
</tr> <tr> <td><font face="Verdana" size="2">Age</font></td>
<td><INPUT Type="text" Name="Age"></td>
</tr> <tr> <td><font face="Verdana" size="2">Email</font></td>
<td><INPUT Type="text" Name="Email"></td>
</tr> <tr> <td><font face="Verdana" size="2">Comment</font></td>
<td><INPUT Type="text" Name="Comment"></td>
</tr> <tr> <td> </td>
<td> <INPUT Type="Submit" Value="Send">
<INPUT Type="Reset" Value="Clear"> </td> </tr> </table>
</form>
</body>
</html>
Feedback.asp file will send the data via the URL and set the file processing form data to file fbresponder.asp. We can make fbresponder.asp file as follows:
<HTML> <HEAD> <TITLE>Your Feedback</TITLE>
</HEAD> <BODY bgColor="lightgrey"><H2>Your Feedback</H2>
<b>Thanks for sending us your feedback.</b><br>
<br>Name : <%=Request.Querystring("Nam")%>
<br>Age : <%=Request.Querystring("Age")%>
<br>Email : <%=Request.Querystring("Email")%>
<br>Comment : <%=Request.Querystring("Comment")%>
</BODY>
</HTML>
For sending data via http headers, just changed the method of data delivery and acceptance form to post data using Request.Form object.