One common problem with having a secure website is that occassionally members will lose or forget their login password. Well, if you collect their email address when they first register, this is an easy problem to handle. You can simply include a "Forgot Password" where the user enters the email address that they registered with and their password will be sent to them immediately.
The first thing you need to do is create a database called MyDatabase. Then create a table called tblUsers with these fields:
ID - autonumber
fUsername - text field
fPassword - text field
fEmail - text field
fDateEntered - date/time field
Now, create a page called password.asp page with the code below
Next, create a page called confirm.asp with the code below:
<% DIM strEmail strEmail = Request.Form("Email") IF strEmail <> "" THEN
%>
<% DIM mySQL, objRS mySQL = "SELECT fEmail,fPassword FROM tblMembers WHERE fEmail = '" & strEmail & "'" Set objRS = Server.CreateObject("ADODB.Recordset") objRS.Open mySQL, objConn IF objRS.EOF THEN Response.Write "That email address was not found in our database. Please click Back on your browser and enter the email address you registered with." ELSE DIM strPassword strPassword = objRS("fPassword") DIM mail, objMail Set objMail = Server.CreateObject("CDONTS.NewMail") objMail.From = "email@yourdomain.com" objMail.Subject = "Password" objMail.To = strEmail objMail.Body = "Here is your login password: " & strEmail objMail.Send Set objMail = nothing Response.Write "Your password has been sent to your email address." END IF ELSE Response.Write "Please click Back on your browser and enter the email address you registered with." END IF %>
In this example, we are using the CDONTS email component to send our email. You can easily replace this with a different email component script like ASPMail or ASPEmail. That's all there is to it. Now, you have a fully automated Forgot Password tool that your website members can use anytime without hassle. That's customer service!
No comments:
Post a Comment