Sorry, the first message was sent in HTML format....here it
is again. I am trying to use CFIF in a mailing list application to
do a few things.
In this case, I want the page to first check if the user is subscribing
and if so, then check the database for the email. If the email doesn't
already exist, it is added to the database and a confirmation is displayed
OR if the email does exist, a message is displayed. It works fine for the
"Add" section, but when it comes to the "Remove" section (which is the
same logic), it displays a blank page if the email doesn't exist in the
database. (It works if the email is in the database). Here's the entire
code:
<CFPARAM NAME="Form.Email"> <CFPARAM NAME="Form.Subscriber">
<CFPARAM NAME="Form.Subscribe"> <!--- Subscribe values = "Add" or
"Remove" --->
<!--- Subscribe user to the mailing list --->
<CFIF "#Form.Subscribe#" IS "Add">
<!--- Query database for Email address submitted on form --->
<CFQUERY NAME="CheckSubscribers" DATASOURCE="GFMaillist1">
SELECT * FROM Subscribers
WHERE Email = '#Form.Email#'
</CFQUERY>
<!--- Check if Email on the form already exists in database----->
<CFIF #CheckSubscribers.Email# IS "#Form.Email#">
<!--- If email already exists, display this message --->
<CFOUTPUT>Your email #Form.Email# already exists in the database.</CFOUTPUT>
<!--- If email doesn't exist, add to the database and send mail--->
<CFELSE>
<!--- Add user to the database--->
<CFQUERY NAME="AddNewSubscriber" DATASOURCE="GFMaillist1">
INSERT INTO Subscribers (Subscriber, EMail)
VALUES ('#Form.Subscriber#', '#Form.EMail#')
</CFQUERY>
<CFOUTPUT><b>Your email #Form.Email# has been successfully added to the
mailing list!</B></CFOUTPUT>
<!--- Send Email confirmation that they have been added --->
<CFMAIL SERVER ="mail.paconline.net" PORT="25" To="#Email#"
FROM="[EMAIL PROTECTED]" SUBJECT="Welcome to the Newsletter!">
Welcome message..
</CFMAIL>
</CFIF></CFIF>
<!--- Remove Subscriber from the mailing list ---->
<CFIF #Form.Subscribe# IS "Remove">
<!-- Check database for email address submitted on form --->
<CFQUERY NAME="CheckEmail" DATASOURCE="GFMaillist1">
SELECT * FROM Subscribers
WHERE Email = '#Form.Email#'
</CFQUERY>
<!--- If email exists, delete from mailing list----->
<CFIF #CheckEmail.Email# IS "#Form.Email#">
<CFQUERY NAME="RemoveUser" DATASOURCE="GFMaillist1">
DELETE FROM Subscribers WHERE Email = '#Form.Email#'
</CFQUERY>
<CFOUTPUT QUERY="CheckEmail">
<B>Your email #Form.Email# has been successfully removed from the mailing
list.</B>
</CFOUTPUT>
<!--- Send removal notification --->
<CFMAIL SERVER ="mail.paconline.net" PORT="25" TO="#Email#"
FROM="[EMAIL PROTECTED]" SUBJECT="Goldenfly mailing list removal
confirmation">
Removal message...</CFMAIL>
<CFELSE>
<!--- if email doesn't exist, display message --->
<CFOUTPUT>
<B>Your email <B>#Form.Email#</B> does not exist in the database.</B>
</CFOUTPUT>
</CFIF></CFIF>
Any help would be appreciated.
thanks,
Kristin
[EMAIL PROTECTED]
------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.