ASP Form Post
The previous lesson ASP
Form Get created
an ASP page to process information
sent through an HTML form with the
GET method. In this lesson we will
be examining how to process data
sent via the POST method and see
how it is different from the last
lesson.
Altering Our HTML Form
Before we begin creating a new
ASP file, we are going to have to
change our "codetellerForm.html"
file to use the POST method and
send the form data to a different
ASP page. The example below
provides the up-to-date code for "codetellerForm.html".
Modified codetellerForm.html Code:
<form method="POST" action="codetellerPost.asp">
Name <input type="text"
name="Name"/>
Age <input type="text"
name="Age"/>
<input type="submit" />
</form> |
Creating an ASP POST Processor
Our new ASP file will be called
"codetellerPost.asp" and will be
saved in the same directory as "codetellerForm.html".
When the POST method is used to
send data you retrieve the
information with the Request
Object's Form collection. So the
only difference between a GET and
POST processor is replacing all
instances of QueryString with
Form.
In the example below we have
made the correct changes and
highlighted them in red.
codetellerPost.asp Code:
<%
Dim name, age
name = Request.Form("Name")
age = Request.Form("Age")
Response.Write("Name: " & name
& "<br />")
Response.Write("Age: " & age &
"<br />")
%> |
ASP POST Processing Simulation
Let's run through a quick
simulation of our ASP processor.
Try this on your computer and make
sure it all works.
codetellerForm.html Filled Out
(not functional):
codetellerPost Result
|
|
|
|