comments in line:

> Hi all,
>
> I'm new at CF and i'm having a few problems with a user login menu.
>
> Specifically;
> 1) If the user just "clicks" submit, without entering any data, I get an
> ERROR message.
> 2) If the user enters a login name that's already taken, I get an ERROR
> message.
>
> Does anyone know how to fix these problems?  Here is the code i'm using
> below.  (I apologize for the length of the message)
>
>
>
> ==================snippet of checklogin.cfm================
> ===========================================================
> Hi,<H2>Please enter your username and password below</H2>
> <cfoutput>
> <cfFORM ACTION="checklogin.cfm" METHOD="POST">
>
> UserName: <cfINPUT TYPE="text" NAME="username1"><BR>
>
> Password: <cfINPUT TYPE="password" NAME="password1"><BR>
>
> <P>
> <INPUT TYPE="submit" VALUE="Submit">
> <INPUT TYPE="reset" VALUE="Clear">
>
> </cfFORM>
> </cfoutput>
> ===========================================================
>
> This goes to checklogin.cfm.  Here i query the database to see
> if the Username (already in the DB) matches the (username1) entered by the
> user.
> Then i try to route the user to the appropriate page. ----->
>
> ====================checklogin.cfm code ====================
> ===========================================================
> <cfquery name="check" datasource="store">
> SELECT Username, Password
> FROM User
> WHERE Username='#username1#'
> </cfquery>

Try this for the query:

<cfquery name="check" datasource="store">
    SELECT Username, Password
    FROM User
    WHERE Username='#Form.username1#' AND Password='#Form.password1#'
</cfquery>

If you don't check for the password then someone could login without one ..
and what would be the point of having one then?

>
> <html>
> <head><title> Check Login Information </title></head>
> <body>
>
> <cfoutput query="check">
> <cfif (Len(Trim("#username1#") IS NOT 0) AND Username IS #username1# AND
> Password IS #password1#>

I think what is happening here is, when the user doesn't enter a username,
your query returns nothing.  Then above, you test for the value of that
query result which doesn't exist ... hence the error.  You need to check to
see if the variable even exists before you can check for its value.
Technicly, if it exists, then the query returned a value which means the
person entered a valid username/password, in which case, you wouldn't even
need to check for the value.

Try

<CFIF IsDefined('username1') AND username1 IS NOT "">

If it's defined and it's not blank, then that's all you really need to care
about, unless you want to perform some other kind of validation on it.

>
> <cfcookie name="name" value="#username1#">
> <cfcookie name="pass" value="#password1#">
> <br>
> <br>
> <center><h2>
> Thanks for logging in to the bookstore.  </h2>
> <br>
> <br>
> <br>Please, click here to go to the main menu.
> Click ---> <a href="usermenu.cfm"> Main Menu</a>
> </center>
> <cfelse>
> <center>
> <h2>
> Were Sorry, your login is taken.</h2>

I don't understand this part .. you check the database to see if their
username is in it so they can log in and then you tell them that their
username is taken?  Well, it's taken by them I would hope :)  You might want
to change the message to something like:  'Invalid username or password'.

> <br>
> <br>
> Please go to the new user section and get a login and password!<br>
> Click-----> <a href="newuser.cfm">New User</a>
> </center>
> </cfif>

Todd

------------------------------------------------------------------------------
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