Here's the code for the Subscribe and Unsubscribe Page.
Subscribe.cfm
<CFIF IsDefined("Email")>
<!--- Insert Member Information Into Database --->
<CFINSERT DATASOURCE="YourDSN" TABLENAME="Newsletter"
Formfields="Name, Email, Subscribe, EmailType">
<CFOUTPUT>
Thank you #Name#,
Your email address [#Email#] Has been entered into our mailing list. You'll receive
the next mailing!
</CFOUTPUT>
<CFELSE>
<!--- Prompt User To Enter information --->
<form action="Subscribe.cfm" method="post">
Name: <input type="Text" Value="" Name="Name"><BR>
Email: <input type="Text" Value="" Name="Email"><BR>
Receive in: Text <input type="Radio" name="EmailType"
value="1"> HTML <input type="Radio" name="EmailType"
value="0">
<input type="Submit" Value="Join Newsletter">
</FORM>
</CFIF>
The unsubscribe page:
unsubscribe.cfm<CFIF IsDefined("Email")>
<CFQUERY DATASOURCE="YourDSN" NAME="Unsubscribe">
DELETE *
From Newsletter
Where Email = '#Email#'
</CFQUERY>
<CFOUTPUT>
<CFIF Unsubscribe.recordcount GTE "1">
Thank you #Name#,
Your email address [#Email#] Has been removed from our mailing list. You'll never
receive mailing again!
<CFELSE>
We're sorry, your email address could not be found! <a href="Javascript:history.go(-1)">try
again</a>?
</CFIF>
</CFOUTPUT>
<CFELSE>
<form action="unsubscribe.cfm" method="post">
Name: <input type="Text" Value="" Name="Name"><BR>
Email: <input type="Text" Value="" Name="Email"><BR>
<input type="Submit" Value="Join">
</FORM>
</CFIF>
Comments