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
"tizagForm.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
"tizagForm.html".
Modified tizagForm.html Code:
<form method="POST" action="tizagPost.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 "tizagPost.asp" and will be saved in the same
directory as "tizagForm.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.
tizagPost.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.
tizagForm.html Filled Out (not functional):
tizagPost.asp Result:
Name: Jack
Age: 15
Found Something Wrong in this Lesson?Report a Bug or Comment on This Lesson - Your input is what keeps Tizag improving with time! |