| << 15.3.0- Coding the Application | Chapter15 | 15.3.2- User Registration and Login >> |
The Home Page
The home page of the application is responsible for welcoming the user to the application, providing some information about what the application is for, and displaying the top-level menu selections for the user. We'll call it Default.asp – this means that the user can simply type in the URL of a virtual directory on our web server, and they'll automatically be directed to this page.
The application's home page will simply display a welcome message, plus some links to other pages that will enable the user to:
- Browse the items that are for sale
- Log into the system (if they are a registered user)
- Register with the system (if they are a new user)
Try It Out – Creating the Home Page
1. Using NotePad, or some other web page editor, create a new ASP file.
2. Enter the following code into your editor (if you want, you can download this file, and all of the other files in this example, from the Wrox web site athttp://www.wrox.com/WileyCDA/WroxTitle/productCd-0764543636,descCd-download_code.html):
<% Session.Abandon %>
<BASEFONT FACE="Comic Sans MS" COLOR="DarkBlue">
<HTML>
<HEAD>
<TITLE>Wrox Classifieds</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFF80">
<CENTER><H1>Wrox Classifieds<BR>Main Menu</H1></CENTER>
<P>Thank you for visiting the Wrox Classifieds website. We offer you the opportunity to:
<UL>
<LI>Browse for items on sale
<LI>Bid for items on sale
<LI>Sell your own items on these pages
</UL>
<P>Feel free to browse our listings - you don't need to register to do that.
If you find an item that you'd like to bid on, or if you'd like to sell something through these pages, we will ask you to register with us.
<HR>
<TABLE BORDER=0 WIDTH=100%>
<TR ALIGN=CENTER>
<TD WIDTH=33%><A href="BrowseListings.asp">Browse the listings</A></TD>
<TD WIDTH=33%><A href="Login.asp">Login</A></TD>
<TD WIDTH=33%><A href="Register.asp">I'm a new user</A></TD>
</TR>
</TABLE>
</BODY>
</HTML>
3. Save the file as Default.asp. Of course, all the .asp files in this application will need to be contained in a folder that is accessible to the web server, so that theASP script within will be processed correctly. I saved the files in my inetpub/wwwroot/BegASPFiles folder.
4. View the page in your web browser:
|
|
How It Works
As you can see from the code, Default.asp is a pretty straightforward web page. The function of this page is twofold: first, to present the user with information about what can be done at this site, and second, to give them the navigation controls needed to begin using the system.
When you look at the page, you'll notice that it is mostly straight HTML. There is only one piece of ASP script in it:
<% Session.Abandon %>
This is the first line of the file, so it's the first statement processed by ASP when a user makes their inaugural visit to the site.
We'll be using session-level variables throughout the application to store information about the current user's session. To be on the safe side, we'll want to reset all of these variables when the user first enters the site. This could prove useful if the application is called up from a public access terminal, where multiple users could be getting in to the site from the same browser. The Abandon method of the Session object will terminate any current user session, thus automatically resetting any session-level variables. This does mean that we expect the user to navigate the site using the supplied links. If they hit the back button on their browser and end up at the default.asp page, then their session will be terminated and they will have to log back on again.
We have placed the navigation controls at the bottom of the page. Each control is just a piece of hyperlinked text, which we use to make certain pages available to the users. At this stage, the only pages that we want to make available are BrowseListings.asp, Login.asp and Register.asp. We'll write these pages shortly.
| << 15.3.0- Coding the Application | Chapter15 | 15.3.2- User Registration and Login >> |

RSS

