Forgotten Password script

A

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/forgotpassword.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.

<form name="Password" method="POST" action="testconfirm.asp">
<table width="100%">
<tr><td>Email:</td>
<td><input type="text" name="Email" size="50">
<input type="submit" name="Submit" value="Submit">
</td></tr></table>
</form>

<%
'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 = "(e-mail address removed)


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

%>
 
S

Stefan B Rusynko

Malformed changes to you script code
Error is on http://www.murraywebs.com/confirm.asp is
Microsoft VBScript compilation error '800a03f6'
Expected 'End'
/confirm.asp, line 67
ELSE

Do you have the all 3 line below on separate lines

IF rsEmail.EOF THEN
Response.Write "That email address was not found in our database. ..."
ELSE

I also see 3 End IF and only 2 IF in your posted code


--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


| 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/forgotpassword.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.
|
| <form name="Password" method="POST" action="testconfirm.asp">
| <table width="100%">
| <tr><td>Email:</td>
| <td><input type="text" name="Email" size="50">
| <input type="submit" name="Submit" value="Submit">
| </td></tr></table>
| </form>
|
| <%
| '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 = "(e-mail address removed)
|
|
| 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
|
| %>
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top