Forgotten Password script

Discussion in 'ASP General' started by Andrew Murray, Apr 26, 2007.

  1. 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 = "


    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

    %>
     
    Andrew Murray, Apr 26, 2007
    #1
    1. Advertising

  2. 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!" (-;
    _____________________________________________


    "Andrew Murray" <> wrote in message news:%23oB$...
    | 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 = "
    |
    |
    | 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
    |
    | %>
    |
    |
    |
     
    Stefan B Rusynko, Apr 26, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alfred E. Newman

    Forgotten Password Reset

    Alfred E. Newman, Feb 23, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    394
    Steve C. Orr [MVP, MCSD]
    Feb 23, 2005
  2. D E
    Replies:
    6
    Views:
    48,462
    rinuthomas
    May 21, 2012
  3. Showjumper

    Handling forgotten passwords

    Showjumper, Jun 12, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    399
    Erik Funkenbusch
    Jun 12, 2006
  4. AAaron123
    Replies:
    2
    Views:
    2,270
    AAaron123
    Jan 16, 2009
  5. AAaron123
    Replies:
    1
    Views:
    1,370
    Oriane
    Jan 16, 2009
Loading...

Share This Page