About Me

Friday, 20 April 2012

ASP Form Post

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="nullvoidPost.asp">
Name <input type="text" name="Name"/>
Age <input type="text" name="Age"/>
<input type="submit" />

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.


Post a Comment