Forgotten Password script

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andrew Murray

    Forgotten Password script

    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/a...ectionopen.asp and
    http://www.aspwebpro.com/aspscripts/...otpassword.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.as p" 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="testcon firm.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("t xtEmail")

    '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.CreateOb ject("ADODB.Con nection")

    'Database connection info and driver

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

    'Set an active connection to the Connection Object

    adoCon.open strCon

    'Create a Recordset Object

    Set rsEmail = Server.CreateOb ject("ADODB.Rec ordset")

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

    strSQL = "SELECT tblUsers.Passwo rd 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.murrayweb s.com"
    strSenderAddr = "webmaster@murr ayebs.com


    strPwd = rsEmail("Passwo rd")
    set objMail = Server.CreateOb ject ("JMail.SMTPMai l")

    objMail.ServerA ddress = 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

    #2
    Re: Forgotten Password script

    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" <adKillSpammers murray@iinet.ne t.auwrote in message news:%23oB$OO5h HHA.5052@TK2MSF TNGP05.phx.gbl. ..
    | 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/a...ectionopen.asp and
    | http://www.aspwebpro.com/aspscripts/...otpassword.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.as p" 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="testcon firm.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("t xtEmail")
    |
    | '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.CreateOb ject("ADODB.Con nection")
    |
    | 'Database connection info and driver
    |
    | strCon="DRIVER= {Microsoft Access Driver (*.mdb);uid=;pw d=;DBQ=" &
    | Server.MapPath( strAccessDB)
    |
    | 'Set an active connection to the Connection Object
    |
    | adoCon.open strCon
    |
    | 'Create a Recordset Object
    |
    | Set rsEmail = Server.CreateOb ject("ADODB.Rec ordset")
    |
    | 'initialise the strSQL variable with a SQL statement to query the database
    |
    | strSQL = "SELECT tblUsers.Passwo rd 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.murrayweb s.com"
    | strSenderAddr = "webmaster@murr ayebs.com
    |
    |
    | strPwd = rsEmail("Passwo rd")
    | set objMail = Server.CreateOb ject ("JMail.SMTPMai l")
    |
    | objMail.ServerA ddress = 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
    |
    | %>
    |
    |
    |


    Comment

    Working...