<html>
<!--- Add cfparams to prevent errors on the page --->
<cfparam name="FORM.Email" default="">
<!--- Create an empty error string --->
<cfset strError = "">
<!--- If the form is submitted --->
<cfif isDefined("FORM.Submit")>
<CFQUERY NAME="GetEmail" dataSource = "#application.datasource#">
SELECT Email
FROM SubscriberTestEmailGroup
WHERE email = <CFQUERYPARAM VALUE="#FORM.EMAIL#" CFSQLTYPE="CF_SQL_VARCHAR">
</CFQUERY>
<cfif GetEmail.recordcount EQ 1>
<cfset strError = strError & "<p>That email is already registered to receive the newsletter">
</CFIF>
<cfquery dataSource = "#application.datasource#">
INSERT INTO SubscriberTestEmailGroup
WHERE Email='#Form.Email#'
</cfquery>
<!--- If the form was not submitted --->
<cfelse>
<!--- Send the user to the form page --->
<cflocation url="http://www.company.com">
</cfif>
<body topmargin="0" bottommargin="0" rightmargin="0" leftmargin="0" bgcolor="#efefef">
<!-- ***************** Email Content Below ***************** -->
<p><!--- If the error string is still empty show the results --->
<cfif strError EQ "">
<!--- Send the email --->
<cfmail
from='"Company" <[email protected]>'
to="#FORM.Email#"
type="text/html"
subject="Welcome">
<table>
<tr><td><p>Welcome text
</td></tr>
</table>
</cfmail>
</cfif>
</body>
</html>
|