[thelist] <cfif> within <cfoutput>?

Seth Bienek - Web Consultant sbienek at acep.org
Fri Jul 7 12:29:08 CDT 2000


Hi ML,

I usually use the query itself to validate the user, then a conditional
afterwards to deal with the state of the login; that way the DB engine is
doing the comparing, significantly faster than CF performing that function:

<cfquery name="Validate" datasource="MyData" maxrows="1">
SELECT ID
FROM Users
<!--- If the ID is numeric, use this: --->
WHERE ID = #val(Form.ID)#
<!--- If the ID the user is entering is text, use this: --->
WHERE ID = '#trim(Form.ID)#'
</cfquery>

<!--- If the above query returns more than 0 records, we're good to go! --->
<cfif Validate.RecordCount>
   You May Enter
<cfelse>
   No Soup for You!
</cfif>

Also, no need to use quotes around variable when you are comparing numbers.
CF (and most SQL engines) consider anything within quotes to be a text
value.

Hope this helps,

Seth

> -----Original Message-----
> From: thelist-admin at lists.evolt.org
> [mailto:thelist-admin at lists.evolt.org]On Behalf Of Minh Lee Goon
> Sent: Friday, July 07, 2000 11:36 AM
> To: evolt
> Subject: [thelist] <cfif> within <cfoutput>?
> 
> 
> I'm trying to validate an ID from an Access DB file. 
> Basically, you log
> in and the CF scripts runs through the table and find that 
> log-in ID. If
> it's there, you pass... if not, no soup for you!
> 
> Now, I have the following:
> <cfoutput query="validate">
>     <cfif form.ID is "#validate.ID#">
>         You may enter
>     <cfelse>
>         No soup for you!
>     </cfif>
> </cfoutput>
> 
> I have the <cfoutput> outside the <cfif> so that it will replace and
> compare the #validate.ID# for every value in that table. It 
> will only go
> through the first value and check it. If I enter a different 
> ID, it just
> kicks me out (as in, the <cfelse> part). Anyone here know 
> what I'm doing
> wrong?
> 
> </ml>
> 
> ---------------------------------------
> For unsubscribe and other options, including
> the Tip Harvester and archive of TheList go to:
> http://lists.evolt.org Workers of the Web, evolt ! 
> 




More information about the thelist mailing list