Thanks Justin :)
couple more ?'s

I havent done much with cfc's beyond the typical show, insert, delete, 
update.....

ok so first ? is if the method is even correct, this is what i imagine it 
should be

<!--- check to see if email is in the database --->
<cffunction name="checkSubscription" 
            access="public" 
            returntype="boolean"
            hint="checks to see if email is in the database" 
            output="true">

    <!--- define arguments --->
    <cfargument name="tbl_email" type="string" required="yes">
    <cfargument name="tbl_name" type="string" required="no">
    <cfargument name="tbl_comments" type="string" required="no">
    <cfset var dupEmail = "">
    
    <!--- 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>
 
    <cfreturn dupEmail.recordCount gt 0>
</cffunction>
-------------------------------------------------------------------------------------
on the subscribe page i have a form which submits to itself then checks the 
existance of the form submission and creates object with form variables

<!--- if the subscribe form was submitted --->
<cfif StructKeyExists(form, "subscribe")>
<!--- invoke subscribe cfc --->
<cfset contactForm = createObject("component","rrcfc.subscribe").addSubscriber(
    tbl_name="#form.name#",
    tbl_email="#form.email#",
    tbl_comments="#form.comments#"
    )>
</cfif>

second ? is lets say it submits and the email is not found in the db how do i 
get the error message back to this page and how do i call it?

also if the email is found how do i then invoke the unsubscribe() method from 
the  checkSubscription() method?

tia again

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

----------------------------------------
From: "Justin D. Scott" <[EMAIL PROTECTED]>
Sent: Sunday, October 30, 2005 9:59 PM
To: CF-Talk <cf-talk@houseoffusion.com>
Subject: RE: cfc ? 

> i cant quite figure this out
> what would be the best way to do this

There are a couple of options off the top of my head.

One would be to create a checkSubscription() method that would return a
boolean value depending on whether the e-mail address was subscribed. If it
is, call the unsubscribe method. If not, display your error. This is
probably the better choice. You can re-use the checkSubscription() method
when someone tries to join the list so it will not add a duplicate, for
example.

The other method would be to use your existing code, but prepend a bit value
to the front of your return value. Example:

After calling the method, you can check the bit value using
listFirst(unSubscriber) to determine if it was successful, and perform
whatever action was needed. Then you can listRest(unSubscriber) to
display/extract your error message.

-Justin Scott



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:222698
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