Justin and Holger nailed it.  I just want to add that your query is
problematic.  Your where clause should always contain both a username and
password.  Don't forget that passwords are not unique.  Also, your code
could produce the nonsensical "where and password = ...".  I'd use
JavaScript on the first form to ensure that a non-blank username and
password have been supplied.
-David

On Wed, 5 Apr 2000 15:36:27 +0200 "Holger Lockertsen"
<[EMAIL PROTECTED]> writes:
> If the recordcount of the query is 0, I don't think the code between 
> the
> <cfoutput>-tags is processed. A better way to do it is:
> 
> <query name="checklogin" datasource="TheSource">TheQuery</query>
> 
> <cfif NOT checklogin.recordcount>
>       <cflocation url="login.cfm?task=loginfailure">
> <cfelse>
>       <cflocation url="Main.cfm?UserID=#checklogin.UserID#">
> </cfif>
> 
> rgds
> 
> 
> * Holger Lockertsen, Solutions Developer, Horisont Information 
> Systems AS
> * Nedre Slottsgate 5, N-0157 OSLO, Noreg/Norway
> * 23 31 03 04 / 91 83 20 51
> * [EMAIL PROTECTED]   http://www.horisont.no/
> 
> NB! Horisont har fått nye nummer, og mitt INTERNNUMMER er: 23 31 03 
> 04
> 
> 
> -----Original Message-----
> From: McDonald, David [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, April 05, 2000 3:15 PM
> To: '[EMAIL PROTECTED]'
> Subject: query.recordcount woes...
> 
> 
> I have been trying to set up a username and password login, which is
> working okay, except for the "failed login" scenario.  The <cfif> 
> tag does
> not
> execute the <cflocation> tag for a failed login (ie. 
> query.recordcount is
> 0).  I'm lost as to why.  Here's my code (called from a previous 
> template
> form supplying the username and password variables):
> 
> <cfquery datasource="fln" name="CheckLogin">
> SELECT UserID, Username, Password, FirstName, LastName
> FROM User
> WHERE
> 
> <cfif Username is not "">Username='#Username#'</cfif> AND
> <cfif Password is not "">Password='#Password#')</cfif>
> </cfquery>
> 
> 
> <cfoutput query="CheckLogin" maxrows=1>
> <cfif CheckLogin.recordcount is 0>
>       <cflocation url="login.cfm?task=loginfailure">
> <cfelse>
>       <cflocation url="Main.cfm?UserID=#UserID#">
> </cfif>
> </cfoutput>
> 
> If the recordcount is not equal to 0 (successful login), it works
> beautifully, but if the recordcount is 0 (failed login), the
> <cflocation url="login.cfm?task=loginfailure"> code does not 
> execute, it
> simply returns a blank page (with the cf server info displayed).
> 
> Anyone help me with this?  It seems very straightforward but has me 
> stumped.

________________________________________________________________
YOU'RE PAYING TOO MUCH FOR THE INTERNET!
Juno now offers FREE Internet Access!
Try it today - there's no risk!  For your FREE software, visit:
http://dl.www.juno.com/get/tagj.
------------------------------------------------------------------------------
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.

Reply via email to