(3 ratings)   
By: msconline.maconstate.edu
The notion is that the user can try again to enter the correct account and password. However, when the logon.asp page is redisplayed, there is no indication to the user what has happened. We can help the user understand the situation better by...
Added: 25 June 2008    Views: 826  
PathComputers    Programming    Asp
Keywords: computers   programming   language   asp   database   functions   code   coder  
Do you like this tutorial? Now you can support our team to add more :     
 
 
 
However, when the logon.asp page is redisplayed, there is no indication to the user what has happened. We can help the user understand the situation better by displaying a message indicating that an incorrect password has been entered. logon.asp

Logon Page

Account:
Password: Incorrect password

The question is, then, how will the logon.asp page know that an incorrect password has been entered so it can display the message? Well, that information has to come from the welcome.asp page, where the password check is made. Thus, the welcome.asp page needs to pass some information to the logon.asp page indicating that an error was made. Then, the logon.asp page will know to display the message.

Query Strings

We have already seen how one page can transmit information to another page through a form. A second method of passing information from one page to another is through a query string. A query string is a set of name/value pairs appended to the end of a URL. You have probably noticed these query strings in your browser's address box in your wanderings around the Web. They take on the general format shown below in bold:

http://www.site.com?name=value&name=value...

A query string is identified by a question mark followed by a collection of one or more names and values. The name/value pairs look and work identically to those transmitted from a form. The difference is that a query string is appended to a URL rather than traveling to the server in a separate data stream.

For the logon application we can make use of a query string to have the welcome.asp page inform the logon.asp page that an incorrect password has been submitted. This is accomplished by appending the query string to the end of the URL that is issued when control is redirected to the logon.asp page. Since the query string is an internal control mechanism for our pages, we can use any name and any value that we choose. Here is the rewrite of the script appearing at the top of the welcome.asp page:

welcome.asp
<%
If Request.Form("Password") <> "xyzzy" Then
  Response.Redirect("logon.asp?PassCheck=No")
End If
%>


We have appended the query string ?PassCheck=No to the end of the logon.asp URL. When the logon.asp page is accessed, the query string will be passed to it.

The Request.QueryString Collection

In a manner similar to which the ASP Request Object gathers form information into its Request.Form Collection, it also gathers query string information into its Request.QueryString Collection. The Request Object intercepts the name/value string following the question mark, parses the string into names and associated values, and places this information into the Request.QueryString Collection. This collection can be visualized as an array of submitted values, each indexed by its associated name. In the following illustration, the query string from the welcome.asp page has been placed into this collection, in this case having a single name and value pair.

The page to which the query string is sent can access names and values in the Request.QueryString Collection in a syntax similar to that used for the Request.Form Collection:

Request.QueryString("name")

where name is the name assigned to a value in the query string. Thus, the reference Request.QueryString("PassCheck") points to the value associated with the name PassCheck that arrives in the query string.

We now need to return to the logon.asp page to add script that looks for this query string and determines whether to display the "Incorrect Password" message.

About the Author :
msconline.maconstate.edu
Passing Query Strings In Asp
Articles and Tutorials Directory by www.learnfobia.com
 Rate this tutorial : Rate 1Rate 2Rate 3Rate 4Rate 5
  |    Add to Favorites
  |    Send to Friend
  |    Print
Comments