TrueBlue
asked on
Want vbscript to execute after submit button is pressed
Hi!
I have the below listed code in an asp page.
I am trying to accomplish the following:
After a user enters their email address in the form's input field and presses the submit button
the vbscript will look in the table for a matching email address if a match is found an email will be sent using the matching email address in the table to the user along with their password. After the email is generated the page will automatically redirect the user to the login page. If a match is not found the no records found function will be called and the user will be redirected to the form's input field and it will be cleared.
Currently, the vbscript is being executed before the submit button is pressed and the email code is being executed before finding a match.
Any ideas?
<%@ Language=VBScript %>
<!-- #include virtual="/AppData.asp" -->
<!-- #include virtual="/adovbs.inc" -->
<!-- #include virtual="/utils.asp" -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="robots" content="noindex, nofollow">
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor. Document">
<title>Forgot Password</title>
<meta name="Microsoft Theme" content="st-pvlogoblue 0011, default">
<meta name="Microsoft Border" content="tlb, default">
</head>
<body>
<form name="form1" onsubmit="if(doSubmit) { return true; } else { return false; }" ACTION="sendpwd.asp" METHOD="POST">
<p align="center">
<b>Please enter your email address below and then press submit button</b>
<input type="text" name=ud_UserEmailAddress>< /input><br ><br>
<input type="submit" name=submit></input>
</p>
<%
Response.Buffer = True
Response.Expires = 0
'Retrieve Password
'Declare all local variables
Dim conn, rs, strsql, strconn
'Set local variable to the connection string and open the connection
strconn = Application("abc_Connectio nString")
Set conn = server.createobject("adodb .connectio n")
conn.open strconn
'Set local recordset variable equal to rs
Set rs = server.createobject("adodb .recordset ")
'Sets the sql query that determine what records get brought back to the asp page.
'This could easily be change to a very specific set of fields or instead of using a ORDER BY statement
'Using a WHERE statement to determine what records get selected
strsql = "SELECT EmailAddress, UserLastName, UserFirstName, LoginPassword FROM dbo.WebAccess WHERE EmailAddress = '" & request("ud_UserEmailAddre ss") & "'"
rs.open strsql, conn
response.write strsql
response.end
If ( (rs.EOF = TRUE) AND (rs.BOF = TRUE) ) Then
Call NoRecordsFound()
Else
Set oMailer = Server.CreateObject("Persi ts.MailSen der")
oMailer.Host = "mail.domain.com" 'Email Server
oMailer.From = "techserv@domain.com" 'specify senders address
oMailer.FromName = "Technical Support" 'specify senders name
Call oMailer.AddAddress(EmailAd dress, UserFirstName & " " & UserLastName)
oMailer.Subject = "Your Password for ??? Web Site"
oMailer.Body = sOutput
oMailer.IsHTML = true
On Error Resume Next
Call oMailer.Send()
If Err <> 0 Then
Response.Write "Error encountered: " & Err.Description
End If
%>
<Form Method=post action="">
<p align="center">
<input type="button" value="Thank You" onClick="window.location=' https://www.secured.domain.com/html/login.htm';" name="ok">
</p>
</Form>
<%
End If
rs.close()
Set rs = Nothing
conn.close()
Set conn = Nothing
'========================= ========== ========== ========== ========== ========== =='
FUNCTION NoRecordsFound
'========================= ========== ========== ========== ========== ========== =='
Set FileObject = Server.CreateObject("Scrip ting.FileS ystemObjec t")
TemplateText = Server.MapPath("HTML/blank .htm")
Set InStream = FileObject.OpenTextFile (TemplateText, 1, False, False)
TemplateText = Empty
While not InStream.AtEndOfStream
TemplateText = TemplateText & InStream.ReadLine & vbcrlf
Wend
Set Instream = Nothing
DIM tmpMsg
tmpMsg = "<a href='JAVASCRIPT:history.b ack();'>No records were found</a>"
TemplateText = Replace(TemplateText,"@Cla rionData@" ,tmpMsg)
Response.Write(TemplateTex t)
Set FileObject = Nothing
END FUNCTION
'------------------------- ---------- ---------- ---------- ---------- ---------- --'
%>
</form>
</body>
</html>
I have the below listed code in an asp page.
I am trying to accomplish the following:
After a user enters their email address in the form's input field and presses the submit button
the vbscript will look in the table for a matching email address if a match is found an email will be sent using the matching email address in the table to the user along with their password. After the email is generated the page will automatically redirect the user to the login page. If a match is not found the no records found function will be called and the user will be redirected to the form's input field and it will be cleared.
Currently, the vbscript is being executed before the submit button is pressed and the email code is being executed before finding a match.
Any ideas?
<%@ Language=VBScript %>
<!-- #include virtual="/AppData.asp" -->
<!-- #include virtual="/adovbs.inc" -->
<!-- #include virtual="/utils.asp" -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="robots" content="noindex, nofollow">
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.
<title>Forgot Password</title>
<meta name="Microsoft Theme" content="st-pvlogoblue 0011, default">
<meta name="Microsoft Border" content="tlb, default">
</head>
<body>
<form name="form1" onsubmit="if(doSubmit) { return true; } else { return false; }" ACTION="sendpwd.asp" METHOD="POST">
<p align="center">
<b>Please enter your email address below and then press submit button</b>
<input type="text" name=ud_UserEmailAddress><
<input type="submit" name=submit></input>
</p>
<%
Response.Buffer = True
Response.Expires = 0
'Retrieve Password
'Declare all local variables
Dim conn, rs, strsql, strconn
'Set local variable to the connection string and open the connection
strconn = Application("abc_Connectio
Set conn = server.createobject("adodb
conn.open strconn
'Set local recordset variable equal to rs
Set rs = server.createobject("adodb
'Sets the sql query that determine what records get brought back to the asp page.
'This could easily be change to a very specific set of fields or instead of using a ORDER BY statement
'Using a WHERE statement to determine what records get selected
strsql = "SELECT EmailAddress, UserLastName, UserFirstName, LoginPassword FROM dbo.WebAccess WHERE EmailAddress = '" & request("ud_UserEmailAddre
rs.open strsql, conn
response.write strsql
response.end
If ( (rs.EOF = TRUE) AND (rs.BOF = TRUE) ) Then
Call NoRecordsFound()
Else
Set oMailer = Server.CreateObject("Persi
oMailer.Host = "mail.domain.com" 'Email Server
oMailer.From = "techserv@domain.com" 'specify senders address
oMailer.FromName = "Technical Support" 'specify senders name
Call oMailer.AddAddress(EmailAd
oMailer.Subject = "Your Password for ??? Web Site"
oMailer.Body = sOutput
oMailer.IsHTML = true
On Error Resume Next
Call oMailer.Send()
If Err <> 0 Then
Response.Write "Error encountered: " & Err.Description
End If
%>
<Form Method=post action="">
<p align="center">
<input type="button" value="Thank You" onClick="window.location='
</p>
</Form>
<%
End If
rs.close()
Set rs = Nothing
conn.close()
Set conn = Nothing
'=========================
FUNCTION NoRecordsFound
'=========================
Set FileObject = Server.CreateObject("Scrip
TemplateText = Server.MapPath("HTML/blank
Set InStream = FileObject.OpenTextFile (TemplateText, 1, False, False)
TemplateText = Empty
While not InStream.AtEndOfStream
TemplateText = TemplateText & InStream.ReadLine & vbcrlf
Wend
Set Instream = Nothing
DIM tmpMsg
tmpMsg = "<a href='JAVASCRIPT:history.b
TemplateText = Replace(TemplateText,"@Cla
Response.Write(TemplateTex
Set FileObject = Nothing
END FUNCTION
'-------------------------
%>
</form>
</body>
</html>
where is your VB script part
ASKER
Hi!
The vb script starts at the line response.buffer = true.
The vb script starts at the line response.buffer = true.
You need to separate your code:
login.asp:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="robots" content="noindex, nofollow">
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor. Document">
<title>Forgot Password</title>
<meta name="Microsoft Theme" content="st-pvlogoblue 0011, default">
<meta name="Microsoft Border" content="tlb, default">
</head>
<body>
<form name="form1" ACTION="sendpwd.asp" METHOD="POST">
<p align="center">
<b>Please enter your email address below and then press submit button</b>
<input type="text" name=ud_UserEmailAddress>< /input><br ><br>
<input type="submit" name=submit></input>
</p>
</form>
</body>
</html>
sendpwd.asp:
<%@ Language=VBScript %>
<!-- #include virtual="/AppData.asp" -->
<!-- #include virtual="/adovbs.inc" -->
<!-- #include virtual="/utils.asp" -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="robots" content="noindex, nofollow">
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor. Document">
<title>Forgot Password</title>
<meta name="Microsoft Theme" content="st-pvlogoblue 0011, default">
<meta name="Microsoft Border" content="tlb, default">
</head>
<body>
<form name="form1" onsubmit="if(doSubmit) { return true; } else { return false; }" ACTION="sendpwd.asp" METHOD="POST">
<p align="center">
<b>Please enter your email address below and then press submit button</b>
<input type="text" name=ud_UserEmailAddress>< /input><br ><br>
<input type="submit" name=submit></input>
</p>
<%
Response.Buffer = True
Response.Expires = 0
'Retrieve Password
'Declare all local variables
Dim conn, rs, strsql, strconn
'Set local variable to the connection string and open the connection
strconn = Application("abc_Connectio nString")
Set conn = server.createobject("adodb .connectio n")
conn.open strconn
'Set local recordset variable equal to rs
Set rs = server.createobject("adodb .recordset ")
'Sets the sql query that determine what records get brought back to the asp page.
'This could easily be change to a very specific set of fields or instead of using a ORDER BY statement
'Using a WHERE statement to determine what records get selected
strsql = "SELECT EmailAddress, UserLastName, UserFirstName, LoginPassword FROM dbo.WebAccess WHERE EmailAddress = '" & request("ud_UserEmailAddre ss") & "'"
rs.open strsql, conn
If ( (rs.EOF = TRUE) AND (rs.BOF = TRUE) ) Then
Call NoRecordsFound()
Else
Set oMailer = Server.CreateObject("Persi ts.MailSen der")
oMailer.Host = "mail.domain.com" 'Email Server
oMailer.From = "techserv@domain.com" 'specify senders address
oMailer.FromName = "Technical Support" 'specify senders name
Call oMailer.AddAddress(EmailAd dress, UserFirstName & " " & UserLastName)
oMailer.Subject = "Your Password for ??? Web Site"
oMailer.Body = sOutput
oMailer.IsHTML = true
On Error Resume Next
Call oMailer.Send()
If Err <> 0 Then
Response.Write "Error encountered: " & Err.Description
End If
%>
<Form Method=post action="">
<p align="center">
<input type="button" value="Thank You" onClick="window.location=' https://www.secured.domain.com/html/login.htm';" name="ok">
</p>
</Form>
<%
End If
rs.close()
Set rs = Nothing
conn.close()
Set conn = Nothing
'========================= ========== ========== ========== ========== ========== =='
FUNCTION NoRecordsFound
'========================= ========== ========== ========== ========== ========== =='
Set FileObject = Server.CreateObject("Scrip ting.FileS ystemObjec t")
TemplateText = Server.MapPath("HTML/blank .htm")
Set InStream = FileObject.OpenTextFile (TemplateText, 1, False, False)
TemplateText = Empty
While not InStream.AtEndOfStream
TemplateText = TemplateText & InStream.ReadLine & vbcrlf
Wend
Set Instream = Nothing
DIM tmpMsg
tmpMsg = "<a href='JAVASCRIPT:history.b ack();'>No records were found</a>"
TemplateText = Replace(TemplateText,"@Cla rionData@" ,tmpMsg)
Response.Write(TemplateTex t)
Set FileObject = Nothing
END FUNCTION
'------------------------- ---------- ---------- ---------- ---------- ---------- --'
%>
login.asp:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="robots" content="noindex, nofollow">
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.
<title>Forgot Password</title>
<meta name="Microsoft Theme" content="st-pvlogoblue 0011, default">
<meta name="Microsoft Border" content="tlb, default">
</head>
<body>
<form name="form1" ACTION="sendpwd.asp" METHOD="POST">
<p align="center">
<b>Please enter your email address below and then press submit button</b>
<input type="text" name=ud_UserEmailAddress><
<input type="submit" name=submit></input>
</p>
</form>
</body>
</html>
sendpwd.asp:
<%@ Language=VBScript %>
<!-- #include virtual="/AppData.asp" -->
<!-- #include virtual="/adovbs.inc" -->
<!-- #include virtual="/utils.asp" -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="robots" content="noindex, nofollow">
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.
<title>Forgot Password</title>
<meta name="Microsoft Theme" content="st-pvlogoblue 0011, default">
<meta name="Microsoft Border" content="tlb, default">
</head>
<body>
<form name="form1" onsubmit="if(doSubmit) { return true; } else { return false; }" ACTION="sendpwd.asp" METHOD="POST">
<p align="center">
<b>Please enter your email address below and then press submit button</b>
<input type="text" name=ud_UserEmailAddress><
<input type="submit" name=submit></input>
</p>
<%
Response.Buffer = True
Response.Expires = 0
'Retrieve Password
'Declare all local variables
Dim conn, rs, strsql, strconn
'Set local variable to the connection string and open the connection
strconn = Application("abc_Connectio
Set conn = server.createobject("adodb
conn.open strconn
'Set local recordset variable equal to rs
Set rs = server.createobject("adodb
'Sets the sql query that determine what records get brought back to the asp page.
'This could easily be change to a very specific set of fields or instead of using a ORDER BY statement
'Using a WHERE statement to determine what records get selected
strsql = "SELECT EmailAddress, UserLastName, UserFirstName, LoginPassword FROM dbo.WebAccess WHERE EmailAddress = '" & request("ud_UserEmailAddre
rs.open strsql, conn
If ( (rs.EOF = TRUE) AND (rs.BOF = TRUE) ) Then
Call NoRecordsFound()
Else
Set oMailer = Server.CreateObject("Persi
oMailer.Host = "mail.domain.com" 'Email Server
oMailer.From = "techserv@domain.com" 'specify senders address
oMailer.FromName = "Technical Support" 'specify senders name
Call oMailer.AddAddress(EmailAd
oMailer.Subject = "Your Password for ??? Web Site"
oMailer.Body = sOutput
oMailer.IsHTML = true
On Error Resume Next
Call oMailer.Send()
If Err <> 0 Then
Response.Write "Error encountered: " & Err.Description
End If
%>
<Form Method=post action="">
<p align="center">
<input type="button" value="Thank You" onClick="window.location='
</p>
</Form>
<%
End If
rs.close()
Set rs = Nothing
conn.close()
Set conn = Nothing
'=========================
FUNCTION NoRecordsFound
'=========================
Set FileObject = Server.CreateObject("Scrip
TemplateText = Server.MapPath("HTML/blank
Set InStream = FileObject.OpenTextFile (TemplateText, 1, False, False)
TemplateText = Empty
While not InStream.AtEndOfStream
TemplateText = TemplateText & InStream.ReadLine & vbcrlf
Wend
Set Instream = Nothing
DIM tmpMsg
tmpMsg = "<a href='JAVASCRIPT:history.b
TemplateText = Replace(TemplateText,"@Cla
Response.Write(TemplateTex
Set FileObject = Nothing
END FUNCTION
'-------------------------
%>
actually, the first file can be a .htm (ie login.htm instead of login.asp)
oops... i forgot to take all the html out of sendpwd.asp, but I'm sure you get the idea
ASKER
Hi!
I broke the html and vbscript into two pages as suggested now the vbscript is executed only after the submit button is pressed, however I am still not getting an email generated.
I placed two response.write statements. I then took the generated strsql value and cut and pasted it into the query analyzer and got the expected results.
However, I get no errors but also get no username from my below listed code.
Here is my current version of the vbscript.
Any ideas what I am missing now?
<%@ Language=VBScript %>
<!-- #include virtual="/AppData.asp" -->
<!-- #include virtual="/adovbs.inc" -->
<!-- #include virtual="/utils.asp" -->
<%
Response.Buffer = True
Response.Expires = 0
'Retrieve Password
'Declare all local variables
Dim conn, rs, strsql, strconn
'Set local variable to the connection string and open the connection
strconn = Application("abc_Connectio nString")
Set conn = server.createobject("adodb .connectio n")
conn.open strconn
'Set local recordset variable equal to rs
Set rs = server.createobject("adodb .recordset ")
'Sets the sql query that determine what records get brought back to the asp page.
'This could easily be change to a very specific set of fields or instead of using a ORDER BY statement
'Using a WHERE statement to determine what records get selected
strsql = "SELECT EmailAddress, UserLastName, UserFirstName, LoginPassword FROM dbo.WebAccess WHERE EmailAddress = '" & request("ud_UserEmailAddre ss") & "'"
rs.open strsql, conn
response.write strsql & chr(13) & chr(10)
response.write "UserName: " & UserLastName
response.end
If ( (rs.EOF = TRUE) AND (rs.BOF = TRUE) ) Then
Call NoRecordsFound()
Else
If "" & rs.Fields("EmailAddress"). Value <> "" Then
Set oMailer = Server.CreateObject("Persi ts.MailSen der")
oMailer.Host = "mail.domain.com" 'Email Server
oMailer.From = rs.Fields("EmailAddress"). Value 'specify senders address
oMailer.FromName = rs.Fields("UserFirstName") .Value & " " & rs.Fields("UserLastName"). Value 'specify senders name
Call oMailer.AddAddress(rs.Fiel ds("EmailA ddress").V alue, UserFirstName & " " & UserLastName)
Call oMailer.AddCC("techserv@do main.com", "Technical Support")
oMailer.Subject = "Your Password for the ??? Web Site"
'Build message body
Body = "Your IP Address: " & Request.ServerVariables("R EMOTE_HOST ") & chr(13) & chr(10)
Body = Body & "Your password is: " & rs.Fields("LoginPassword") .Value & chr(13) & chr(10)
oMailer.Body = Body
oMailer.IsHTML = true
On Error Resume Next
Call oMailer.Send()
If Err <> 0 Then
Response.Write "Error encountered: " & Err.Description
End If
Else
%>
<script language="javascript" type="text/javascript">jav ascript: window.history.back(-2)</s cript>
<%
End IF
End If
rs.close()
Set rs = Nothing
conn.close()
Set conn = Nothing
'========================= ========== ========== ========== ========== ========== =='
FUNCTION NoRecordsFound
'========================= ========== ========== ========== ========== ========== =='
Set FileObject = Server.CreateObject("Scrip ting.FileS ystemObjec t")
TemplateText = Server.MapPath("HTML/blank .htm")
Set InStream = FileObject.OpenTextFile (TemplateText, 1, False, False)
TemplateText = Empty
While not InStream.AtEndOfStream
TemplateText = TemplateText & InStream.ReadLine & vbcrlf
Wend
Set Instream = Nothing
DIM tmpMsg
tmpMsg = "<a href='JAVASCRIPT:history.b ack();'>No records were found</a>"
TemplateText = Replace(TemplateText,"@Cla rionData@" ,tmpMsg)
Response.Write(TemplateTex t)
Set FileObject = Nothing
END FUNCTION
'------------------------- ---------- ---------- ---------- ---------- ---------- --'
%>
I broke the html and vbscript into two pages as suggested now the vbscript is executed only after the submit button is pressed, however I am still not getting an email generated.
I placed two response.write statements. I then took the generated strsql value and cut and pasted it into the query analyzer and got the expected results.
However, I get no errors but also get no username from my below listed code.
Here is my current version of the vbscript.
Any ideas what I am missing now?
<%@ Language=VBScript %>
<!-- #include virtual="/AppData.asp" -->
<!-- #include virtual="/adovbs.inc" -->
<!-- #include virtual="/utils.asp" -->
<%
Response.Buffer = True
Response.Expires = 0
'Retrieve Password
'Declare all local variables
Dim conn, rs, strsql, strconn
'Set local variable to the connection string and open the connection
strconn = Application("abc_Connectio
Set conn = server.createobject("adodb
conn.open strconn
'Set local recordset variable equal to rs
Set rs = server.createobject("adodb
'Sets the sql query that determine what records get brought back to the asp page.
'This could easily be change to a very specific set of fields or instead of using a ORDER BY statement
'Using a WHERE statement to determine what records get selected
strsql = "SELECT EmailAddress, UserLastName, UserFirstName, LoginPassword FROM dbo.WebAccess WHERE EmailAddress = '" & request("ud_UserEmailAddre
rs.open strsql, conn
response.write strsql & chr(13) & chr(10)
response.write "UserName: " & UserLastName
response.end
If ( (rs.EOF = TRUE) AND (rs.BOF = TRUE) ) Then
Call NoRecordsFound()
Else
If "" & rs.Fields("EmailAddress").
Set oMailer = Server.CreateObject("Persi
oMailer.Host = "mail.domain.com" 'Email Server
oMailer.From = rs.Fields("EmailAddress").
oMailer.FromName = rs.Fields("UserFirstName")
Call oMailer.AddAddress(rs.Fiel
Call oMailer.AddCC("techserv@do
oMailer.Subject = "Your Password for the ??? Web Site"
'Build message body
Body = "Your IP Address: " & Request.ServerVariables("R
Body = Body & "Your password is: " & rs.Fields("LoginPassword")
oMailer.Body = Body
oMailer.IsHTML = true
On Error Resume Next
Call oMailer.Send()
If Err <> 0 Then
Response.Write "Error encountered: " & Err.Description
End If
Else
%>
<script language="javascript" type="text/javascript">jav
<%
End IF
End If
rs.close()
Set rs = Nothing
conn.close()
Set conn = Nothing
'=========================
FUNCTION NoRecordsFound
'=========================
Set FileObject = Server.CreateObject("Scrip
TemplateText = Server.MapPath("HTML/blank
Set InStream = FileObject.OpenTextFile (TemplateText, 1, False, False)
TemplateText = Empty
While not InStream.AtEndOfStream
TemplateText = TemplateText & InStream.ReadLine & vbcrlf
Wend
Set Instream = Nothing
DIM tmpMsg
tmpMsg = "<a href='JAVASCRIPT:history.b
TemplateText = Replace(TemplateText,"@Cla
Response.Write(TemplateTex
Set FileObject = Nothing
END FUNCTION
'-------------------------
%>
Change
If ( (rs.EOF = TRUE) AND (rs.BOF = TRUE) ) Then
to
If NOT rs.EOF Then
If ( (rs.EOF = TRUE) AND (rs.BOF = TRUE) ) Then
to
If NOT rs.EOF Then
ASKER
Hi!
I changed the code as suggested.
If I enter a valid email address I get no records found.
If I enter a non-existent email address I get the following error:
ADODB.Field error '800a0bcd'
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
It refers to this line of code:
If "" & rs.Fields("EmailAddress"). Value <> "" Then
I think the problem still stems from the fact that no data is being returned from the sql select statement.
I just do not know why.
I changed the code as suggested.
If I enter a valid email address I get no records found.
If I enter a non-existent email address I get the following error:
ADODB.Field error '800a0bcd'
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
It refers to this line of code:
If "" & rs.Fields("EmailAddress").
I think the problem still stems from the fact that no data is being returned from the sql select statement.
I just do not know why.
ASKER
Hi!
Update I went back to my original code of:
If ( (rs.EOF = TRUE) AND (rs.BOF = TRUE) ) Then
And the no records found is being called properly for an non-existent email address.
Like I said the problem now is why is no data being returned from a properly formated sql select statement?
Update I went back to my original code of:
If ( (rs.EOF = TRUE) AND (rs.BOF = TRUE) ) Then
And the no records found is being called properly for an non-existent email address.
Like I said the problem now is why is no data being returned from a properly formated sql select statement?
ASKER
Hi!
I got the email working now.
So the only thing not working, is that the javascript is not redirecting the user to the login page.
<script language="javascript" type="text/javascript">jav ascript: window.history.back(-2)</s cript>
Any ideas?
Or is there a way to send the user to a specific page upon the email being executed?
I got the email working now.
So the only thing not working, is that the javascript is not redirecting the user to the login page.
<script language="javascript" type="text/javascript">jav
Any ideas?
Or is there a way to send the user to a specific page upon the email being executed?
What was the problem? While I was looking at the code, I cleaned up the email section. Also the redirect will work with this:
If rs.BOF OR rs.EOF Then
Call NoRecordsFound()
Else
If rs.Fields("EmailAddress"). Value <> "" Then
Set oMailer = Server.CreateObject("Persi ts.MailSen der")
oMailer.Host = "mail.domain.com" 'Email Server
oMailer.From = rs.Fields("EmailAddress"). Value 'specify senders address
oMailer.FromName = rs.Fields("UserFirstName") .Value & " " & rs.Fields("UserLastName"). Value 'specify senders name
Call oMailer.AddAddress(rs.Fiel ds("EmailA ddress").V alue, UserFirstName & " " & UserLastName)
Call oMailer.AddCC("techserv@do main.com", "Technical Support")
oMailer.Subject = "Your Password for the ??? Web Site"
'Build message body
Body = "Your IP Address: " & Request.ServerVariables("R EMOTE_HOST ") & chr(13) & chr(10)
Body = Body & "Your password is: " & rs.Fields("LoginPassword") .Value & chr(13) & chr(10)
oMailer.Body = Body
oMailer.IsHTML = true
On Error Resume Next
Call oMailer.Send()
If Err <> 0 Then
Response.Write "Error encountered: " & Err.Description
End If
End If
Response.Redirect("some url")
If rs.BOF OR rs.EOF Then
Call NoRecordsFound()
Else
If rs.Fields("EmailAddress").
Set oMailer = Server.CreateObject("Persi
oMailer.Host = "mail.domain.com" 'Email Server
oMailer.From = rs.Fields("EmailAddress").
oMailer.FromName = rs.Fields("UserFirstName")
Call oMailer.AddAddress(rs.Fiel
Call oMailer.AddCC("techserv@do
oMailer.Subject = "Your Password for the ??? Web Site"
'Build message body
Body = "Your IP Address: " & Request.ServerVariables("R
Body = Body & "Your password is: " & rs.Fields("LoginPassword")
oMailer.Body = Body
oMailer.IsHTML = true
On Error Resume Next
Call oMailer.Send()
If Err <> 0 Then
Response.Write "Error encountered: " & Err.Description
End If
End If
Response.Redirect("some url")
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi!
I believe what is happening is the hosting company is somehow disabiling the ability to response.write data from the sql table. Because the script works fine now but if I try to display returned data other than the sql string I get no value.
Thank you for your assistance and patience.
I believe what is happening is the hosting company is somehow disabiling the ability to response.write data from the sql table. Because the script works fine now but if I try to display returned data other than the sql string I get no value.
Thank you for your assistance and patience.
You're welcome. Thank-you for the points! :)