Newsletter - Posted (1112 Views)
Senior Member
leatherlips
Posts: 1838
1838
I have decided to use this asp newsletter. I would like to change one thing in it.
There is a small form on the page that allows you to enter your email address to subscribe. The page then refreshes to give you more instructions.
What I would like it to do is when it refreshes is to have the form not appear any longer. How would I do this?
Here is the code for the page. The section in red is the part that I would like to not appear once an email is entered:

Code:
<%@ Language = VBScript %>
<!-- #include file = "variables.asp" -->
<%
Email = request.form("Email")

'Send an email to the bugger to confirm the email address
if len(Email) <> 0 then

'Time to open the database
set con = server.createObject("ADODB.Connection")
con.open(strServerConnection)

'Check whether email exists
sqlString = "Select Email from Newsletter where Email = '"&Email&"'"
set rs = con.execute(sqlString)

'Return error if email already exists
while not rs.eof
if rs("Email") = Email then

output = "This email is already in our database."
blnError = true

end if
rs.moveNext
wend

if not blnError then

sqlString = "Insert into Newsletter (Email, Status) values ('"&Email&"', 0)"
con.execute(sqlString)
con.close

'Compose email message here
Message = "To confirm your subscription for our newsletter at "&CompanyName&" ("&DomainName&")," &vbCrLf
Message = Message & "simply click on the following link:" & vbCrLf & "http://"&DomainName&"/newsletter/newsletterConfirmation.asp?email="&Email
Message = Message & vbCrLf & vbCrLf & "If you did not sign up for this newsletter, please ignore this mail." &vbCrLf
Signature = vbCrLf & "Important: Do not reply to this email." & vbCrLf & vbCrLf & "____________________" & vbCrLf
Signature = Signature & CompanyName & vbCrLf & "http://"&DomainName

set newMailObj = server.createObject("CDONTS.NewMail")
newMailObj.BodyFormat = 1
newMailObj.MailFormat = 0

newMailObj.from = "no-reply@"&replace(DomainName, "www.", "")
newMailObj.to = Email
newMailObj.subject = CompanyName & " Newsletter Signup Confirmation."
newMailObj.body = Message & Signature
newMailObj.send
set newMailObj = nothing

output = "Signup successfully. <p>Please check your mailbox to confirm your subscription and activate your account."
end if
end if
%>
<html><!-- #BeginTemplate "/Templates/User_Newsletter.dwt" --><!-- DW6 -->
<head>
<!-- #BeginEditable "doctitle" -->
<title><%=CompanyName%> - Newsletter Subscription</title>
<!-- #EndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="styles.css" type="text/css">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<table width="60%" border="1" cellspacing="1" cellpadding="1" align="center" bordercolor="#000033">
<tr>
<td><!-- #BeginEditable "contents" -->
<p><b>Newsletter Subscription</b></p>
<p><%=output%></p>
<p>
<font color="red"><form name="newsletterForm" method="post" action="subscribeNewsletter.asp">
<b>Email: </b>
<input type="text" name="Email" size="30">
<input type="submit" name="Submit2" value="Signup">
</form></font id="red">
<!-- #EndEditable --></td>
</tr>
<tr>
<td>
<!-- Please do not remove this to support future releases of this script -->
<div align="center"><span class="tiny">myNewsletter version <%=ScriptVersion%><br>
<a href="http://www.aspburst.com" target="_blank">ASP Burst (http://www.aspburst.com)</a></span>
<!-- End footer -->
</div></td>
</tr>
</table>
</body>
<!-- #EndTemplate --></html>
 Sort direction, for dates DESC means newest first  
 Page size 
Posted
Advanced Member
Carefree
Posts: 4224
4224
Simple enough.
Find this line (appx 52) - note, I changed "successfully" to "successful" for grammatical correctness:
Code:

      output = "Signup successful. <p>Please check your mailbox to confirm your subscription and activate your account."
After that, add the following line:
Code:

	Response.Write	"<meta http-equiv=""Refresh"" content=""2; URL=default.asp"">" & vbNewLine

That will give a 2 second pause before going back to your default.<
Posted
Senior Member
leatherlips
Posts: 1838
1838
Thanks Carefree.
After I posted this I played around with it. I ended up doing the following.
I copied the page and renamed it. I then set the action in the form to go to the new page. On the new copied page I removed the form.
This way all of the confirmation and error messages still work.
I decided to abandon the other Newsletter MOD because it was kind of a mess as far as getting things to look right. The script I found is simple and works for what I need it for.<
Posted
Advanced Member
Carefree
Posts: 4224
4224
Long way around, but if you're happy with it, fine.<
Posted
Advanced Member
Carefree
Posts: 4224
4224
I finally figured out why the html version looked like crap. I had the test server set to use jmail and it doesn't support html.<
Posted
Senior Member
leatherlips
Posts: 1838
1838
Maybe I'll go back to the original Newsletter MOD and see if I can get it to work for me.<
 
You Must enter a message