i cant quite figure this out

what would be the best way to do this

If i have a mailing list and the user wants to unsubscribe, I take the the 
email from the unsubscribe form and invoke the cfc. I can get it to unsubscribe 
fine but I want to add some code to check too be sure the email is in the db 
first and if not return an error if it is run the unsubscribe query.

the main problem I am getting is the error message back, not quite sure how to 
display it

on unsubscribe page i create the cfc object if the form was submitted
<!--- if the unsubscribe form was submitted --->
<cfif StructKeyExists(form, "unsubscribe")>
<!--- invoke subscribe cfc --->
<cfset unSubscriber = 
createObject("component","rrcfc.subscribe").unSubscriber(tbl_email="#form.email#")>
</cfif>

in the cfc

<!---updates unsubscribe form submission to db --->
<cffunction name="unSubscriber" access="public" returntype="string" 
hint="checks email address to see if its in database" output="true">
    <!--- define arguments --->
    <cfargument name="tbl_email" type="string" required="yes">
    
    <!--- check database for email address --->
    <cfquery name="dupEmail" datasource="#request.datasource#" 
username="#request.username#" password="#request.password#">
    SELECT tbl_email
    FROM jtbl_mailingList
    WHERE tbl_email = <cfqueryparam value="#tbl_email#" 
cfsqltype="cf_sql_varchar">
    </cfquery>
    
    <!--- Check to see if the email is in the database if not send a not found 
message back, if found change to unsubscribe --->
    <cfif dupEmail.recordcount EQ 0>
    <cfset result = "That email address was not found in our mailing list">
    <cfreturn result>
    <cfelse>
    
    <!--- update to unsubscribed now --->
    <cfquery datasource="#request.datasource#" username="#request.username#" 
password="#request.password#">
    UPDATE             jtbl_mailingList
    SET                tbl_subscribe = <cfqueryparam value="no" 
cfsqltype="cf_sql_varchar">,
                    tbl_unsubscribeDate = <cfqueryparam 
value="#DateFormat(Now(), 'ddd, dd mmm yyyy')#" cfsqltype="cf_sql_date">,

    WHERE            tbl_email = <cfqueryparam 
value="#trim(HTMLEditFormat(tbl_email))#" cfsqltype="cf_sql_varchar">
    </cfquery>
    
    <cfset result = "You have been unsubscribed.">
    <cfreturn result>
    </cfif>
</cffunction>
</cfcomponent>

should i make it 2 different methods?
and how do i call the result? 

tia

~Dave the disruptor~
"Some people just don't appreciate how difficult it is to dispense wisdom and 
abuse at the same time." 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:222687
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to