Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Been looking at my code too loooong to see the problem....

Status
Not open for further replies.

TonyU

Technical User
Feb 14, 2001
1,317
US
Ok guys, here's what I'm doing

1. I have one field form where I ask for the username
2. I'm sending this form to a page called getpassword.asp (below)
[/tt]



GetPassword.asp

<%@LANGUAGE=&quot;VBSCRIPT&quot;%>
<!--#include file=&quot;Connections/conn.asp&quot; -->
<%
Dim rsEmail__MMColParam
rsEmail__MMColParam = &quot;1&quot;
if (Request.QueryString(&quot;loginname&quot;) <> &quot;&quot;) then rsEmail__MMColParam = Request.QueryString(&quot;loginname&quot;)
%>
<%
set rsEmail = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rsEmail.ActiveConnection = MM_conn_STRING
rsEmail.Source = &quot;SELECT * FROM Users WHERE login = '&quot; + Replace(rsEmail__MMColParam, &quot;'&quot;, &quot;''&quot;) + &quot;'&quot;
rsEmail.CursorType = 0
rsEmail.CursorLocation = 2
rsEmail.LockType = 3
rsEmail.Open()
rsEmail_numRows = 0
%>
<%
Do While (NOT rsEmail.BOF) AND (NOT rsEmail.EOF)
%>
<%
'***********************************************************
Dim objMsg, strFrom, strTo, strSubject, strBody, lngImportance
strFrom = &quot;Lost Password Retrival Department&quot;
'****************************** THIS LINE IS FOR TESTING ONLY
strTo = rsEmail(&quot;email&quot;)
'****************************** THIS LINE IS FOR TESTING ONLY
strSubject = &quot;Your ...:: Lost Password Request ::... &quot;
strBody = &quot;Dear: &quot; & rsEMail(&quot;First&quot;) & &quot;&quot; & rsEmail(&quot;Last&quot;) & &quot;<br>&quot; & &quot;Your login password is: &quot; & rsEMail(&quot;password&quot;) & &quot;<br>&quot; & &quot;Thank you for your request.&quot;
strFile = &quot;bar.bmp&quot;

Set objMsg = Server.CreateObject(&quot;CDONTS.NewMail&quot;)

objMsg.From = strFrom
objMsg.To = strTo
objMsg.Subject = strSubject
objMsg.Body = strBody

objMsg.Send

Set objMsg = Nothing
rsEmail.MoveNext()
rsEmail.Close()
loop
'Wend
%>
<%
response.redirect &quot;%>


3. The page processes without errors but I don't get the email. Could someone please help me with this one.

It's been a long day... Thanks in advance.





<%=Tony%>
Just trying to learn...
Got ASP Error(s)? =
 
Hmm, to much javascript on the brain? :)

First thing I see is this:
Code:
rsEmail.Source = &quot;SELECT * FROM Users WHERE login = '&quot; + Replace(rsEmail__MMColParam, &quot;'&quot;, &quot;''&quot;) + &quot;'&quot;
Switch the +'s to &'s

2nd, not an error, but you may want to change the &quot;login =&quot; portion of your SQL statement to &quot;login LIKE&quot; for case insensitivity. Not really necessary, depends on how much you care about your users using the correct case.

3rd, again, not an error, but you probably don't want the email in a loop, there should only be 1 user with that login name, so you may want to just do a simple if/then check.

4th, check the Event viewer in Administrative Tools for possible errors

5th, double check that you have a default forwarding SMTP address on the machine. This is setup either by setting up a default account on Outlook/Outlook Express/etc, Running a Mail Server on the local machine, or Administrative Tools &gt; Internet Services Manager &gt; Rt Click on Default Web, sleect Properties &gt; Server Extensions tab &gt; Options section: Settings button: fill out SMTP mail server.

Let me know if you finish all these and still have a problem.

-Tarwn

--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
 
[tt]

Thanks Tarwn, I'll give it a shot when I get to the office tomorrow morning.
<%=Tony%>
Just trying to learn...
Got ASP Error(s)? =
 
Hi TonyU,
You may also want to check your Looping condition. The:

Do While (NOT rsEmail.BOF) AND (NOT rsEmail.EOF) line.

For a newly openned recordset, the BOF should be true. As such, the loop will not execute ...

regards,
- Joseph
================= ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Shopping --> , Soccer --> ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
 
The BOF should only be true if there is nothing in the recordset, otherwise it will be pointing at one of the records. If it is an unordered recordset it will nearly always be pointing to the first record, if it is an ordered recordset it won't necessarally be pointing to the first record, but what would be the first record in the set if it was unordered. Unless you movePrev a lot in your code you shouldn't generally hit a BOF.

-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
 
I have made changes to the email page but it's still not working and I don't see why. It's actually giving me an error at line 24
I read the error at aspfaq.com but did not understand it.

Code:
<%@LANGUAGE=&quot;VBSCRIPT&quot;%> 
<!--#include file=&quot;Connections/myconn.asp&quot; -->
<%
dim myuser
[COLOR=blue]myuser[/color] = request.form(&quot;loginname&quot;)
%>
[COLOR=green]here I'm simply displaying the value passed from my form 
'The log in name requested is: <%=myuser%> 
[/color]
<%
set rsEmail = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rsEmail.ActiveConnection = MM_myconn_STRING
rsEmail.Source = &quot;SELECT email FROM Users WHERE login = '&quot; & [COLOR=blue]myuser[/color]
rsEmail.CursorType = 0
rsEmail.CursorLocation = 2
rsEmail.LockType = 3
rsEmail.Open()
rsEmail_numRows = 0
%>
<%
[COLOR=green]'***********************************************************[/color]
Set objMsg = Server.CreateObject(&quot;CDONTS.NewMail&quot;)
Dim objMsg, strFrom, strTo, strSubject, strBody, lngImportance
strFrom = &quot;Lost Password Request Department&quot;
[COLOR=green]'****************************** THIS LINE IS FOR TESTING ONLY[/color]
[COLOR=red][b]strTo = rsEmail(&quot;email&quot;)[/color][/b]
[COLOR=green]'****************************** THIS LINE IS FOR TESTING ONLY[/color]
strSubject = &quot;...:: Lost Password Request ::... &quot;
strBody = &quot;Dear: &quot; & rsEMail(&quot;First&quot;) & &quot;&quot; &  rsEmail(&quot;Last&quot;) & &quot;<br>&quot; & &quot;Your login password is: &quot; & rsEMail(&quot;password&quot;) & &quot;<br>&quot; & &quot;Thank you for your request.&quot;
strFile = &quot;bar.bmp&quot;


objMsg.From = strFrom
objMsg.To = strTo
objMsg.Subject = strSubject
objMsg.Body = strBody

objMsg.Send

Set objMsg = Nothing
%>
<%
response.redirect &quot;[URL unfurl="true"]http://mysite/login.asp&quot;[/URL]
%>


P.S. I also need to know how to check if the name submitted actually exist in my database before sending this email but not sure how to apply it to this code.

Your input is greatly appreciated.

[bugeyed][hammer][cry]




<%=Tony%>
Just trying to learn...
Got ASP Error(s)? =
 
[tt]I apologize for the second post, thought the first one did not go thru.
<%=Tony%>
Just trying to learn...
Got ASP Error(s)? =
 
Well, your select statement your already submitting should work to verify the user as well, just check for EOF or BOF before reading the email field, if there are no rows returned, they don't exist and the recordset will be EOF and BOF, if they do exist, there will be a row returned (at least one that is) and it won't be EOF or BOF. This may also be whats causing your error, it may not be passing the login name correctly in your SQL stmt, causing an empty (EOF) recordet to come back.

-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top