After receiving a few queries about how to store passwords using ACCESS and ASP, and then use them as “logins”, I thought, well, why not write in a separate article, instead of attaching multiple ASP files that are full of confusing comments and variables only to be decipherable by my brain?
I’m assuming you’ve installed, and are running PWS (Personal Web Server) on your machine, if you are not already working on a server that supports ASP.
First of all, create a database, for instance, customers.Define a table with all the fields you require (include email and password).
After the database has been created, you need to create a DNS in order to access this database through your ASP pages.
If you have never created it, this is how you do it:
Go to the Control Panel (My Computer -> Control Panel), and click on the icon that should be saying “ODBC Data Sources (32bit)”. In the resulting window, select the “System DSN” tab. Then click on the “Add…” button. From the given list of Database drivers, select “Microsoft Access Driver (*.mdb)” and click the “Finish” button. You reach a place where you have to enter the “Data Source Name”. Enter it, anything, for instance, “customers”. Then click the “Select…” button. This lets you select the Access database you created. Press Ok, press Ok, and press Ok. Your DSN is created.
In the first part, I’ll write about storing the passwords.
File name: sessions.inc
This file you can include in every page as
so that you can use them whenever you need them.
Now accepting login and password.
For this you require a normal HTML form. You can have “n” number of fields in a form, but here, our primary concern is, getting the email as login, and the accompanying password.
Here’s the form:
We validate the form before it proceeds to the “action” file so that there is very little server-side processing. A simple validation:
So now when the user clicks on “Submit”, he/she goes to “storelog.asp” In between, you can have a file to confirm the form fields and give the user an option to modify them before finally saving.
A few things. In order to use a database through ASP, you need to have a DNS created for that database on the server.
STORELOG.ASP should somewhat look like this:
This saves the login information of a new customer. Now, how do we use it in the future? First, the login form, that could be on any page.
At the top of the page, along with other ASP commands, include this too:
This is required if you want to send the user to some page after he/she has successfully logged in.
From now onwards, whenever you want to perform some action that should only be performed if the user is logged in, just check the value is session(“email”), like:
Hope this helps. If you need further queries, or in future you need some other ASP work, you are welcome to write to me at amrit@b…
Amrit Hallan is a freelance copywriter,
and a website content writer. He also dabbles
with PHP and HTML. For more tips and tricks in
HTML, visit his blog at