Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Sample Code for "Forgot Password"
 New Topic  Topic Locked
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 2

mafifi
Junior Member

USA
308 Posts

Posted - 08 May 2001 :  22:27:58  Show Profile  Send mafifi an ICQ Message
I am trying to implement a "Forgot Password" feature similar to the one on Snitz Forum on another web site. Any ideas which files, from Snitz, I should look at.

Thanks,

Mo

RichardKinser
Snitz Forums Admin

USA
16655 Posts

Posted - 08 May 2001 :  22:40:37  Show Profile
pop_pword.asp
Go to Top of Page

mafifi
Junior Member

USA
308 Posts

Posted - 08 May 2001 :  22:50:32  Show Profile  Send mafifi an ICQ Message
Hi Richard,
I looked at the file that you mentioned but when I click on the link that I created, the Pop-Up Window will open and I get an "HTTP 500 Internal Server Error".

However, I'm using a different snipett of code and I do not get any e-mail notification back. Please take a look.
quote:

<%@Language=VBScript%>
<%Response.Buffer=True%>

<html>
<body>

<%
username = Trim(Request.Form("email"))
If Len(email) < 1 Then
%>

<center><font color="blue">Forget your password?</font><p>
<table>
<form method="post">
<tr><td><center>Please Enter Your <b>Email Address</b></center></td></tr>
<tr><td><center><input type="text" name="email"></center></td></tr>
<tr><td><center><input type="submit" value="Submit"></center></td></tr>
</table>
</form>
</center>

<%
Else
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=d:\INETPUB\WWWROOT\XYZ.mdb"

sql = "SELECT Email, PassWord FROM TABLEA WHERE Email = '"&email&"'"
Set RS = Conn.Execute(sql)

If RS.EOF Then
Response.write "<p><br><br><br><center>Invalid Email Address!</center>"
Else
password = RS("password")
Call SendPW(email, password)
Response.Write "<p><br><br><br><center>Your Password has been sent!</center>"

RS.Close
Conn.Close
Set RS = Nothing
Set Conn = Nothing
End If
End If

Sub SendPW(email, password)
Set cdoMail = Server.CreateObject("CDONTS.NewMail")
cdoMail.From = "webmaster@yourdomain.com"
cdoMail.To = email
cdoMail.Subject = "Your requested password."
cdoMail.Body = password & vbcrlf & vbcrlf & vbcrlf _
& "*** THIS MESSAGE HAS BEEN AUTOMATICALLY GENERATED ***"

cdoMail.Send
Set cdoMail = Nothing
End Sub
%>

</body>
</html>



Mo
Go to Top of Page

RichardKinser
Snitz Forums Admin

USA
16655 Posts

Posted - 08 May 2001 :  23:49:46  Show Profile
Try turning off "Show friendly HTTP error messages" in Internet Explorer so you will get a description of the error instead of the default HTTP 500 error screen.
Go to Top of Page

MorningZ
Junior Member

USA
169 Posts

Posted - 08 May 2001 :  23:55:45  Show Profile  Visit MorningZ's Homepage  Send MorningZ an AOL message
if i had to guess...

cdoMail.Body = password & vbcrlf & vbcrlf & vbcrlf _
& "*** THIS MESSAGE HAS BEEN AUTOMATICALLY GENERATED ***"

shouls be

cdoMail.Body = password & vbcrlf & vbcrlf & vbcrlf & _
"*** THIS MESSAGE HAS BEEN AUTOMATICALLY GENERATED ***"

but for sure turn off friendly ( "Tools", "Internet Options", "Advanced", down half way uncheck "Show Friendly Errors" ) as Richard says

Go to Top of Page

tilttek
Junior Member

Canada
333 Posts

Posted - 09 May 2001 :  09:05:56  Show Profile  Visit tilttek's Homepage
quote:

cdoMail.Body = password & vbcrlf & vbcrlf & vbcrlf _
& "*** THIS MESSAGE HAS BEEN AUTOMATICALLY GENERATED ***"
shouls be
cdoMail.Body = password & vbcrlf & vbcrlf & vbcrlf & _
"*** THIS MESSAGE HAS BEEN AUTOMATICALLY GENERATED ***"



That not it for sure... The two codes (here) work well...

Philippe Gamache
http://www.tilttek.com
http://www.lapageamelkor.com
Go to Top of Page

mafifi
Junior Member

USA
308 Posts

Posted - 09 May 2001 :  16:37:51  Show Profile  Send mafifi an ICQ Message
MorningZ & tilttek,

I tried the two variations of the code and still do not receive any e-mail back. I even tried it on a differnt servers. Any one out there wants to take a shot at running the code to see if it works or not.

Thanks,

Mo

Edited by - mafifi on 09 May 2001 16:38:34
Go to Top of Page

mafifi
Junior Member

USA
308 Posts

Posted - 09 May 2001 :  20:10:22  Show Profile  Send mafifi an ICQ Message
I found a nice sample code at http://www.4guysfromrolla.com/webtech/093000-1.shtml and it works!

Thanks,

Mo
Go to Top of Page

mafifi
Junior Member

USA
308 Posts

Posted - 09 May 2001 :  20:16:42  Show Profile  Send mafifi an ICQ Message
Sorry. Wrong article.
http://www.4guysfromrolla.com/webtech/043000-1.shtml

Mo
Go to Top of Page

tilttek
Junior Member

Canada
333 Posts

Posted - 10 May 2001 :  09:52:55  Show Profile  Visit tilttek's Homepage
quote:

MorningZ & tilttek,
I tried the two variations of the code and still do not receive any e-mail back. I even tried it on a differnt servers. Any one out there wants to take a shot at running the code to see if it works or not.



You need the SMTP install and configure when using CDO (or CDONT).

Maybe if you give us the error you receive. If you don't have any error, it most likely the SMTP gateway.

Philippe Gamache
http://www.tilttek.com
http://www.lapageamelkor.com

Edited by - tilttek on 10 May 2001 09:54:43
Go to Top of Page

mafifi
Junior Member

USA
308 Posts

Posted - 10 May 2001 :  21:36:15  Show Profile  Send mafifi an ICQ Message
tilttek,


quote:

You need the SMTP install and configure when using CDO (or CDONT).



CDONTS is installed on my server (readyhosting.com) and it's also installed on the server at work. I am not receiving any errer messages. What happens is that after I submit the form, it comes back (the form) and I do not receive any e-mail.

Thanks,


Mo
Go to Top of Page

tilttek
Junior Member

Canada
333 Posts

Posted - 11 May 2001 :  11:01:24  Show Profile  Visit tilttek's Homepage
quote:

CDONTS is installed on my server (readyhosting.com) and it's also installed on the server at work. I am not receiving any errer messages. What happens is that after I submit the form, it comes back (the form) and I do not receive any e-mail.



CDONTS need the SMTP service... And have a tendency to do nothing it the SMTP isn't configure properly. You won't receive any Error.



Philippe Gamache
http://www.tilttek.com
http://www.lapageamelkor.com
Go to Top of Page

mafifi
Junior Member

USA
308 Posts

Posted - 12 May 2001 :  10:22:15  Show Profile  Send mafifi an ICQ Message
I am positive that there is something wrong with the code because the code from http://www.4guysfromrolla.com/webtech/043000-1.shtml is working fine and I receive the e-mail notification without any problems. I checked the SMTP on both servers and it's configured O.K.

Thanks,

Mo
Go to Top of Page

tilttek
Junior Member

Canada
333 Posts

Posted - 14 May 2001 :  09:27:27  Show Profile  Visit tilttek's Homepage
quote:

I am positive that there is something wrong with the code because the code from http://www.4guysfromrolla.com/webtech/043000-1.shtml is working fine and I receive the e-mail notification without any problems. I checked the SMTP on both servers and it's configured O.K.



Can't see anyting can you send us the EXACT code you use (maybe along with the one form 4Guys). A real cut and paste, witout any modification. If you don't what to write all info, you might want to send it to my email: philippe@gamache.com

Philippe Gamache
http://www.tilttek.com
http://www.lapageamelkor.com
Go to Top of Page

mafifi
Junior Member

USA
308 Posts

Posted - 14 May 2001 :  15:51:45  Show Profile  Send mafifi an ICQ Message
Call this file forgot.asp
<html>
<head>
<title>Forgot Password?</title>
</head>
<body>
If you forgot your login information, enter you email
address below and it will be sent to you.

<form method="POST" action="sendit.asp">
Your email address:
<input type="text" name="email" size="20">
<input type="submit" value="Request information">
</form>
</body>
</html>


Call this file sendit.asp
 <%@ 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("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>
<body>
<%
'checks if email address exists in the database before sending a message.
if objrs.EOF then
%>
<B><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 = "webmaster@yoursite.com"
'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
%>

Your login information has been mailed to <%=email%>.<br>
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%>



Thanks,

Mo
Go to Top of Page

tilttek
Junior Member

Canada
333 Posts

Posted - 15 May 2001 :  09:15:59  Show Profile  Visit tilttek's Homepage
quote:


& "Password=" & pass & vbCrlf
'this sets mail priority.... 0=low 1=normal 2=high
sendmail.Importance = 2
sendmail.Send
%>




Strange, can seem to find any problem with this... I'll try tonight...
Remember on WIN2000 CDONTS is call CDO, so if you're with win2000 might be the problem.

Philippe Gamache
http://www.tilttek.com
http://www.lapageamelkor.com
Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Next Page
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.53 seconds. Powered By: Snitz Forums 2000 Version 3.4.07