The ASP On Line Course:
Using the REQUEST Object
ASP is very commonly used to process form requests - having the user type in something, and then either mailing or storing or writing this information out. Learn more about how the request object works and how to use it to boost your website's functionality.
The REQUEST object is a way that information is passed from one webpage to another. Usually this is done by creating a link that looks something like this:
The ? after the URL lets your code know that anything after the ? is values for you to work with. Each name-value pair is separated by an &. You can have as many pairs as you wish.
This same syntax is generated by a GET type of form. To create this, you would create a form something like this on a webpage:
<FORM action="SendMessage.asp" method="GET>
What is your username? <INPUT TYPE="TEXT" NAME="username">
What is your email address? <INPUT TYPE="TEXT NAME="email">
So in essence, the form is just like any regular HTML form. You can now use your ASP script to process the results of the form, and do whatever you want with that information.
Let's take a look at the SendMessage.asp file that this information is being sent to - either by a direct URL link or through this form. It's very easy to get your hands on that incoming information!
UserName = Request("username")
EmailAddress = Request("email")
Response.write "The username submitted is: " & UserName
Response.Write " and the email address submitted is: " & EmailAddress
That's it! Just use Request(fieldname) to get your hands on the value in any fieldname being passed in. You can then use this information to send mail messages, write information to the database, customize your webpages, and much, much more.
ASP Course and Code | HTML Tips, Code & Help | Java Code & Help | Gaming Walkthroughs