To read the article online, visit

Emailing Users their Forgotten Passwords

By 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 to sendit.asp. Keep in mind there is no error checking here, you may want to add that to avoid apostrophe problems.

  <title>Forgot Password?</title>
If you forgot your login information, enter you email
address below and it will be sent to you.

<form method="POST" action="sendit.asp">
  Your email address:
  <input type="text" name="email" size="20">
  <input type="submit" value="Request information">

The second page, sendit.asp is what actually does the work. We'll look at the source code for SendIt.asp in detail in Part 2.

  • Read Part 2

  • Article Information
    Article Title: Emailing Users their Forgotten Passwords
    Article Author: Eric Coffman
    Published Date: Sunday, April 30, 2000
    Article URL:

    Copyright 2019 QuinStreet Inc. All Rights Reserved.
    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers