Lost Password

Discussion in 'Classic ASP' started by ntreescom00, May 8, 2003.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Can any one help me with this ASP CDONTS email code. i.e. Customer lost password enter email to retrieve password. I get HTTP 500 error when I run this code.

    <%@ LANGUAGE="VBSCRIPT" %>
    <% Option Explicit %>
    <%
    Dim DATA_PATH, objDC, objRS, email, user, pass, sendmail
    'Maps to database. Change to your database path.
    DATA_PATH=Server.Mappath("db/users.mdb")
    ' Create and establish data connection
    Set objDC = Server.CreateObject("ADODB.Connection")
    objDC.ConnectionTimeout = 15
    objDC.CommandTimeout = 30
    objDC.Open "DBQ=" & DATA_PATH & _
    ";Driver={Microsoft Access Driver (*.mdb)}; " & _
    "DriverId=25;MaxBufferSize=8192;Threads=20;", _
    "admin", "password"
    Set objRS = Server.CreateObject("ADODB.Recordset")
    email=request.form("email")
    'you may need to adjust this to suit your database
    objRS.Open "SELECT * FROM USERS WHERE email = '" & _
    email & "'", objDC, 0, 1
    %>

    <head>
    <title>Forgotten Password</title>
    </head>

    <%
    'checks if email address exists in the database
    'before sending a message.
    if objrs.EOF then
    %>
    <font color="red">
    There is no account for <%=email%>.
    </font></B>
    <% Else %>

    <%
    'sets variables
    email = request.form("email")
    'chooses username and password from database that correspond
    'to submitted email address.
    user = objrs.Fields("username")
    pass = objrs.Fields("password")
    Set sendmail = Server.CreateObject("CDONTS.NewMail")

    'put the webmaster address here
    sendmail.From = "[email protected]"

    'The mail is sent to the address entered in the previous page.
    sendmail.To = email

    'Enter the subject of your mail here
    sendmail.Subject = "The Login Information You Requested"

    'This is the content of thr message.
    sendmail.Body = "The login Information you requested." & _
    vbCrlf & vbCrlf & "Username=" & user & _
    vbCrlf & "Password=" & pass & vbCrlf

    'this sets mail priority.... 0=low 1=normal 2=high
    sendmail.Importance = 2

    sendmail.Send 'Send the email!
    %>


    Your login information has been mailed to <%=email%>.

    You should receive it shortly.
    <%
    ' Close Data Access Objects and free DB variables
    objDC.Close
    Set objRS = Nothing
    Set objDC = Nothing
    Set sendmail = Nothing
    %>
    <%end if%>
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    FIrst thing you do is to configure your browser to display the 'real' error message.

    Follow the instruction in this article, http://kb.discountasp.net/article.aspx?id=10052

    If you still couldn't resolve the problem, try post the exact error.


    quote:Originally posted by ntreescom00

    Can any one help me with this ASP CDONTS email code. i.e. Customer lost password enter email to retrieve password. I get HTTP 500 error when I run this code.

    <%@ LANGUAGE="VBSCRIPT" %>
    <% Option Explicit %>
    <%
    Dim DATA_PATH, objDC, objRS, email, user, pass, sendmail
    'Maps to database. Change to your database path.
    DATA_PATH=Server.Mappath("db/users.mdb")
    ' Create and establish data connection
    Set objDC = Server.CreateObject("ADODB.Connection")
    objDC.ConnectionTimeout = 15
    objDC.CommandTimeout = 30
    objDC.Open "DBQ=" & DATA_PATH & _
    ";Driver={Microsoft Access Driver (*.mdb)}; " & _
    "DriverId=25;MaxBufferSize=8192;Threads=20;", _
    "admin", "password"
    Set objRS = Server.CreateObject("ADODB.Recordset")
    email=request.form("email")
    'you may need to adjust this to suit your database
    objRS.Open "SELECT * FROM USERS WHERE email = '" & _
    email & "'", objDC, 0, 1
    %>

    <head>
    <title>Forgotten Password</title>
    </head>

    <%
    'checks if email address exists in the database
    'before sending a message.
    if objrs.EOF then
    %>
    <font color="red">
    There is no account for <%=email%>.
    </font></B>
    <% Else %>

    <%
    'sets variables
    email = request.form("email")
    'chooses username and password from database that correspond
    'to submitted email address.
    user = objrs.Fields("username")
    pass = objrs.Fields("password")
    Set sendmail = Server.CreateObject("CDONTS.NewMail")

    'put the webmaster address here
    sendmail.From = "[email protected]"

    'The mail is sent to the address entered in the previous page.
    sendmail.To = email

    'Enter the subject of your mail here
    sendmail.Subject = "The Login Information You Requested"

    'This is the content of thr message.
    sendmail.Body = "The login Information you requested." & _
    vbCrlf & vbCrlf & "Username=" & user & _
    vbCrlf & "Password=" & pass & vbCrlf

    'this sets mail priority.... 0=low 1=normal 2=high
    sendmail.Importance = 2

    sendmail.Send 'Send the email!
    %>


    Your login information has been mailed to <%=email%>.

    You should receive it shortly.
    <%
    ' Close Data Access Objects and free DB variables
    objDC.Close
    Set objRS = Nothing
    Set objDC = Nothing
    Set sendmail = Nothing
    %>
    <%end if%>

    </blockquote id="quote"></font id="quote">
     
  3. Thanks Burce
    I had forgot to configure my browser to display the 'real' error message. Its now working.
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page