Java Reference
In-Depth Information
Password VARCHAR(20) NOT NULL,
MemberID int IDENTITY);
Notice that the UserName column has been defined as the primary key but not as a clustered key,
because the physical layout of a SQL Server database is ordered on the clustered key, if assigned. This
means that if a new member is added with a clustered key value within the current range of clustered
key values, as might easily be the case, the entire table will be reshuffled to reflect the change. This
clearly has an adverse impact on performance if you sign up a lot of new members.
The importance of the MemberID column is easiest to understand when you consider a situation where
you have to access member information from another table. When the user logs in, the first thing you do
is look up his UserName and password in the Login Table. This lookup also returns the MemberID,
which can be used to look up any other data you may need. Table 12-2 illustrates a member name and
address table that can be indexed by MemberID for rapid access.
Table 12-2: Member Name and Address Table
MemberI
D
FNAM
E
LNAME
STREE
T
CIT
Y
S
T
ZIP
EMAIL
1
Giorgio
Corleon
e
123
Main St
NY
N
Y
1000
2
gcorleone@hotmail.co
m
Creating the Login Page
The user interface between the member and the database is based on the use of HTML forms.
Members log in to the Web site by using a simple HTML form. The screen shot of Figure 12-1 shows
the HTML form in an Opera browser window. The HTML for the login form is shown in Listing 12-2 .
Figure 12-1: HTML login form displayed in the Opera browser
Listing 12-2: Using HTML to create a basic login form
<html>
<head>
<title>Member Login</title>
</head>
<body bgcolor="#c0c0c0">
<form method="POST" action="servlet/LoginServlet">
<table>
<tr>
<td colspan=2>
<h3>Please log in:</h3>
</td>
Search WWH ::




Custom Search