Emailing Users their Forgotten PasswordsBy Eric Coffman
A few months ago I decided it was time to learn ASP. I started out using some code samples from around the web, and eventually learned to write some of it myself. I recently read Sams Teach Yourself Active Server Pages 3.0 in 21 Days which helped me clean up my coding techniques.
I work at a large university that has many online courses. Due to the creation time involved in preparing an entire course for the net, and to keep others from plagiarizing the material, we password protect much of the content. We use an access database to keep all students names, email addresses, usernames, and passwords that are enrolled in the particular class and have them log in to the the courses with that information. Although this method works quite well to allow only the members of a particular class access to the course material, the students, especially at the start of a semester, often forget their login information. Last semester I decided it was time to stop the "I forgot my password" emails, and wrote this script.
I use the CDONTS component that comes with IIS to do the sending. (For a good article on CDONTS, check out:
Sending Email Using CDONTS.) Basically what happens is a person who has
forgotten their login information is directed to a page that asks for their email address. The page posts the
entered email address to a second page which checks if the email address entered is in the database. If the
email address is not there, the user will be prompted as such. If the email address is there, the script sends
an email to the address entered with the username and password for that person in the message body. We assume
that your user database has a username, password, and an email field and the database table is called
USERS. Now that we know what we are doing lets see how.
The first page,
forgot.asp is just a basic form that gathers a users email address and posts it
sendit.asp. Keep in mind there is no error checking here, you may want to add that to avoid
The second page,
sendit.asp is what actually does the work.
We'll look at the source code for
SendIt.asp in detail in