|
Free printable Sudoku Puzzles | Custom Word Search Puzzles | iptocountry.info | Free web storage |
| GET and POST methods and how to get info from them |
There are two ways we may get info from users by using a form: GET and POST methods. Additionally, GET method may be used for other porpoises as a regular link. Let´s check both methods
POST method
This method will be indicated in the form we are using to get information
from user as shown in the example bellow
| <form method="POST" action="getandpostgetinfo.asp">
Your name<BR> <input type=text name=thename size=15><BR> Your age<BR> <input type=text name=theage size=15><BR> <input type=submit value="Send info"> </form> |
When submitting the form we will visit the URL bellow (will be different when using GET method):
http://www.asptutorial. info/sscript/getandpostgetinfo.aspWhen getting information from the form in the response page we will use Request.Form command
| Code | Output |
| <% =Request.form %> | thename=John&theage=30 |
| <% =Request.form ("thename") %> | John |
| <% =Request.form ("theage") %> | 30 |
| <%
Theage=Request.form ("theage") Thename=Request.form ("thename") Response.write("Hi " & Thename & ", I know you are " & Theage & " years old") %> |
Hi John, I know you are 30 years old |
GET method
This method may be used exactly as in the example above, but the URL we will visit after submission will be diferent.
In the example bellow we have replace the word "POST" and "GET" has
been written instead.
| <form method="GET" action="getandpostgetinfo.asp">
Your name<BR> <input type=text name=thename size=15><BR> Your age<BR> <input type=text name=theage size=15><BR> <input type=submit value="Send info"> </form> |
When submitting the form we will visit the URL bellow (will be different when using GET method):
http://www.asptutorial. info/sscript/getandpostgetinfo.asp?thename=John&theage=30When getting information from the form in the response page we will use Request.Querystring command.
| Code | Output |
| <% =Request.Querystring %> | thename=John&theage=30 |
| <% =Request.Querystring ("thename") %> | John |
| <% =Request.Querystring ("theage") %> | 30 |
| <%
Theage=Request.Querystring ("theage") Thename=Request.Querystring ("thename") Response.write("Hi " & Thename & ", I know you are " & Theage & " years old") %> |
Hi John, I know you are 30 years old |
Get method may be used for additonal porpoises. In the example bellow
it is shown data in different ways depending on request.querystring values
obtained from the the url visited. Try
it.
| Getandpostexample.asp Try it |
| <html>
<body bgcolor=FFFFFF> <pre> <b>Information about my friends</b> <% if request.querystring="showall" then %>
<a href=Getandpostexample.asp>Hide data</a>
<% if request.querystring("name")="Anna" then%>
<a href=Getandpostexample.asp?showall>Show all data</a> <% end if %>
|
|
|
Create word search puzzles with your own words
|
2008@ AspTutorial.info. All rights reserved.