Skip to main content
Participant
May 23, 2008
Question

Another login problem - or is my query at fault?

  • May 23, 2008
  • 2 replies
  • 613 views
I’m pretty new to CF (and coding in general) but am ‘enjoying’ the learning experience….slowly coming to grips with it but I will stress the ‘slowly’!

OK I have Ben Forta’s CFMX7 WACK and am trying to implement a basic user authentication/login page. (pretty much copied from Pages 624-628).

I am using MX7 and my testing server is on my local machine. My database is MS Access.

Here is my problem: when I submit the username and password in my form on the loginForm.cfm page, the LoginCheck.cfm page runs, but I receive the error message that
“The required parameter FORM.USERLOGIN was not provided. “

Since the first two lines of code on this page are
<cfparam name="FORM.userLogin" type="string">
<cfparam name="FORM.userPassword" type="string">

Pretty basic error, but one that I can’t quite understand. Where are the values going to…?

Here is the complete LoginForm code:
<!--check user is logged in and authenticate -->
<cfif isDefined("Form.UserLogin")>
<cfinclude template="LoginCheck.cfm">
</cfif>


<html>
<head>
<title>Login</title>
</head>
<!-- place cursor in "username" field when page loads -->

<body onLoad="document.LoginForm.userLogin.focus();">
<!-- start login form-->
<cfform action="LoginCheck.cfm" name="LoginForm" method="post">
<!--make the UserLogin and UserPassword fields required-->
<input type="hidden" name="userLogin_required">
<input type="hidden" name="userPassword_required">
<table>
<tr><th colspan="2" align="center">Please Login</th></tr>
<tr>
<td align="right">
SwapperID:
</td>
<td>
<cfinput type="text"
name="userLogin"
size="20"
value=""
maxlength="4"
required="yes"
mask="AA99"
message="A valid ID is required. Please register if you don't have one."
>
</td>
</tr>
<tr>
<td align="right">
Password:
</td>
<td>
<cfinput type="password"
name="userPassword"
size="20"
value=""
maxlength="100"
required="yes"
message="Password is required."
>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<cfinput type="submit"
name="submit"
value="login"
validate="submitOnce">
</td>
</tr>
</table>
</cfform>
</body>
</html>


[Aside: the “place cursor in "username" field when page loads” code doesn’t work either.]

PROBLEM2
I am wondering if this is a similar problem to that which I was getting when writing an update page (for members details). For some reason even though I was using a valid userID in the URL, I was passing empty strings when trying to populate the form fields. Ie #user.surname# (etc) was empty

Here is the query:
<!--get the user record-->
<cfquery datasource="mydns" name="user">
SELECT userID, firstname, surname, email, address, city, state, postcode, referal
FROM users
WHERE userID='#URL.userID#'
</cfquery>


Are these two problems related? Any help would be much appreciated.
This topic has been closed for replies.

2 replies

Inspiring
May 23, 2008
You have a logic problem.

Your cfparam tag ensures that your isDefined function will always return true. This means your loginCheck.cfm will always be included, even if no form was submitted.

Inspiring
May 23, 2008
Your form needs to have the exact name

name="LoginForm should be name="USERLOGIN"

"enm181" <webforumsuser@macromedia.com> wrote in message
news:g16e5r$oba$1@forums.macromedia.com...
> I?m pretty new to CF (and coding in general) but am ?enjoying? the
> learning
> experience?.slowly coming to grips with it but I will stress the ?slowly?!
>
> OK I have Ben Forta?s CFMX7 WACK and am trying to implement a basic user
> authentication/login page. (pretty much copied from Pages 624-628).
>
> I am using MX7 and my testing server is on my local machine. My database
> is MS
> Access.
>
> Here is my problem: when I submit the username and password in my form on
> the
> loginForm.cfm page, the LoginCheck.cfm page runs, but I receive the error
> message that
> ?The required parameter FORM.USERLOGIN was not provided. ?
>
> Since the first two lines of code on this page are
> <cfparam name="FORM.userLogin" type="string">
> <cfparam name="FORM.userPassword" type="string">
>
> Pretty basic error, but one that I can?t quite understand. Where are the
> values going to??
>
> Here is the complete LoginForm code:
> <!--check user is logged in and authenticate -->
> <cfif isDefined("Form.UserLogin")>
> <cfinclude template="LoginCheck.cfm">
> </cfif>
>
>
> <html>
> <head>
> <title>Login</title>
> </head>
> <!-- place cursor in "username" field when page loads -->
>
> <body onLoad="document.LoginForm.userLogin.focus();">
> <!-- start login form-->
> <cfform action="LoginCheck.cfm" name="LoginForm" method="post">
> <!--make the UserLogin and UserPassword fields required-->
> <input type="hidden" name="userLogin_required">
> <input type="hidden" name="userPassword_required">
> <table>
> <tr><th colspan="2" align="center">Please Login</th></tr>
> <tr>
> <td align="right">
> SwapperID:
> </td>
> <td>
> <cfinput type="text"
> name="userLogin"
> size="20"
> value=""
> maxlength="4"
> required="yes"
> mask="AA99"
> message="A valid ID is required. Please register if you don't have one."
> >
> </td>
> </tr>
> <tr>
> <td align="right">
> Password:
> </td>
> <td>
> <cfinput type="password"
> name="userPassword"
> size="20"
> value=""
> maxlength="100"
> required="yes"
> message="Password is required."
> >
> </td>
> </tr>
> <tr>
> <td colspan="2" align="center">
> <cfinput type="submit"
> name="submit"
> value="login"
> validate="submitOnce">
> </td>
> </tr>
> </table>
> </cfform>
> </body>
> </html>
>
>
> [Aside: the ?place cursor in "username" field when page loads? code
> doesn?t
> work either.]
>
> PROBLEM2
> I am wondering if this is a similar problem to that which I was getting
> when
> writing an update page (for members details). For some reason even though
> I was
> using a valid userID in the URL, I was passing empty strings when trying
> to
> populate the form fields. Ie #user.surname# (etc) was empty
>
> Here is the query:
> <!--get the user record-->
> <cfquery datasource="mydns" name="user">
> SELECT userID, firstname, surname, email, address, city, state, postcode,
> referal
> FROM users
> WHERE userID='#URL.userID#'
> </cfquery>
>
>
> Are these two problems related? Any help would be much appreciated.
>
>