In my opinion, one of the most annoying things about some websites is logging in. Today, Mitchell will demonstrate how to create a nifty little feature that will allow your site to "remember" its visitors.
Hey... I Remember You! - Storing the users login details (Page 2 of 7 )
In our example, we will create a simple three-page site. The first page will be where we add new users. The second where the user signs up, and the third will be the page that they get access to if their login details were validated OK.
To store our login details, we will create a one-tabled database with Enterprise Manager (We could use query analyser, but why complicate it?). So, jump across to your web server and fire up Enterprise Manager (Start -> Programs -> Microsoft SQL Server -> Enterprise Manager). Expand the node of the database server on which you want to create the database (By default, you'll only have one). Right click on the "Databases" node and choose the "New Database..." option. In the name field, enter "smartlogin" and click the OK button at the bottom.
Ok, now to create our table. Under the "Databases" node, you'll find a "smartlogin" node (our newly created database). Expand that node and right click on the "Tables" node. Choose the "New Table..." option. Create the table with the fields shown in the following diagram:
So, your new table should have three fields: id, user_name and password. To reduce the chance of data duplication, we will create our "id" field as a special field called a "unique identity". Pay close attention to the options of our Id field above: Notice how the Identity field is set to "yes" and both the identity seed and increment fields are 1. This basically means "the id field will be a unique field that will start with the value of 1. Every time a new record is added, its value will be one more than the previous record".
Close the window and save the table as "logins". Now that we've got all of the database design our of the way, we're ready to create the page that will allow us to add users to our logins table.