Forgotten Password script

Forgotten Password script

am 26.04.2007 01:43:39 von Andrew Murray

I'm a novice at coding and cannot get the script below to work I'm
receiving an Error 500 in the web browser when trying to run this script.
The site is www.murraywebs.com and the link is 'Retrieve Password' under the
logon form. the idea is to submit an email address and the password is
emailed to the user. (a very "basic" but common function of user management
systems).

The script(s) I'm using are based on
http://www.aspwebpro.com/tutorials/asp/dbconnectionopen.asp and
http://www.aspwebpro.com/aspscripts/websitetools/forgotpassw ord.asp. I've
made some adaptions to these scripts, because as they are, they don't work
either.

I'm using the JMail component on a Windows 2003 Server through my hosting
service www.spiritconnect.com.au

First there's a page with a email-form with one text field called "Email"
and a submit button that calls "confirm.asp" which contains the function to
send the password to the users email address.


Appreciate any help in troubleshooting. Code is below.




Email:




<%
'Dimension variables
DIM adoCon 'database connection variable
DIM strCon 'Holds Database drive and the path and the name of the database
DIM rsEmail 'Database Recordset variable
DIM strAccessDB ' holds name of the database
DIM strSQL 'Database query string
DIM strEmail 'Holds the email address of the user

'initalised the Email variable
strEmail = Request.Form("txtEmail")

'initialise the strAccessDB variable with the name of the Access Database

strAccessDB="/fpdb/murraywebs.mdb"

'if check for End of File

IF strEmail <> "" THEN

'create a connection object

Set adoCon = Server.CreateObject("ADODB.Connection")

'Database connection info and driver

strCon="DRIVER={Microsoft Access Driver (*.mdb);uid=;pwd=;DBQ=" &
Server.MapPath(strAccessDB)

'Set an active connection to the Connection Object

adoCon.open strCon

'Create a Recordset Object

Set rsEmail = Server.CreateObject("ADODB.Recordset")

'initialise the strSQL variable with a SQL statement to query the database

strSQL = "SELECT tblUsers.Password FROM tblUsers WHERE tblUsers.Email = '"
& strEmail & "'"

'Query the Database

rsEmail.Open strSQL, strCon

'Check Recordset for matching email until EOF and if not found return error
page (Redirect)

IF rsEmail.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 strPwd 'holds password from database to send by email to strEmail
Dim objMail 'an instance of Persits ASPEmail
Dim strSenderAddr 'holds sender address which is the web server/site
Dim strSMTPServer 'holds name of the outgoing mail server


strSMTPServer = "mail.murraywebs.com"
strSenderAddr = "webmaster@murrayebs.com


strPwd = rsEmail("Password")
set objMail = Server.CreateObject ("JMail.SMTPMail")

objMail.ServerAddress = strSMTPServer
objMail.Sender = strSenderAddr
objMail.Sender = strEmail
objMail.Subject = "Password Request from Murraywebs.com"
objMail.Body = "You requested your password by email:" & strEmail & crlf
objMail.Execute

Set objMail = Nothing

END IF

END IF

END IF

'close connection and all objects
Set adoCon = Nothing

%>