okay all, im trying to make a password protected section on the site. I've used the following code from ww.sys-con.com
from their Auguest CF article, written by Kelly Brown under heading "simple Security"
-------
<!--- Turn On Session variables --->
<cfapplication name="AccessSecurity"
sessionmanagement="Yes"
setclientcookies="Yes"
sessiontimeout="#CreateTimeSpan(0, 2, 0, 0)#">
<!-- If not logged in, run login procedure --->
<CFIF NOT IsDefined("Session.user_id">
<CFSET message="">
<!--- If submitting login form, process it --->
<CFIF IsDefined("Form.login">
<!--- Check login and password --->
<cfquery name="check" datasource="users">
SELECT user_id
FROM users
WHERE email='#FORM.securitylogin#'
and password='#FORM.securitypassword#'
</cfquery>
<!--- If user found set session variable,
otherwise set error message --->
<CFIF check.RecordCount IS NOT 0>
<CFSET Session.user_id=check.user_id>
<CFELSE>
<CFSET message="Invalid Login.">
</CFIF>
</CFIF>
<!--- If logging in or invalid login
show login form --->
<CFIF NOT IsDefined("Form.login" or
message IS NOT "">
<html><head><title>User Login</title></head>
<body bgcolor="white">
<P align="CENTER"><B>Login</B></P>
<CFIF message IS NOT "">
<CFOUTPUT><P align="CENTER"><FONT color="red">
<B>#message#</B></font></P>
</CFOUTPUT><P>
</CFIF>
<!--- Extract the current file name from template
path and append the url parameters--->
<CFOUTPUT>
<FORM
action="#GetFileFromPath(CF_TEMPLATE_PATH)
#?#CGI.QUERY_STRING#" method="POST">
</cfoutput>
<!--- Create all passed in form variables as
hidden form fields --->
<CFIF IsDefined("Form.FieldNames">
<CFLOOP INDEX="ThisVar" list="#Form.FieldNames#">
<CFIF ThisVar IS NOT "securitylogin" AND
ThisVar IS NOT "securitypassword">
<CFOUTPUT>
<input type=hidden
name="#ThisVar#"
value="#Evaluate("Form.#ThisVar#"#">
</cfoutput>
</cfif>
</cfloop>
</cfif>
<DIV align="center">
<TABLE border="0" cellspacing="0">
<TR>
<TD align=right><B>Email</B></TD>
<TD><input name="securitylogin" size=40></TD>
</TR>
<TR>
<TD align=right><B>Password</B></TD>
<TD><input type="password"
name="securitypassword"
size=15></TD>
</TR>
</TABLE>
<P>
<input type=submit value="Login" name="login">
</FORM>
</div>
</body>
</html>
<!--- Stop the template here when logging in,
ignoring the rest of page --->
<CFABORT>
</CFIF>
<!--- If our login was okay we fall through to the
rest of the page --->
</CFIF>
-----
Now i know that according to this it needs a datasource "users" and a table called "users"
now im not sure, i've made a table using ACCESS 2000 and made teh datasource... everything connects cept i get the follwing error :
"Error Diagnostic Information
ODBC Error Code = 07001 (Wrong number of parameters)
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2.
Hint: The cause of this error is usually that your query contains a reference to a field which does not exist. You should verify that the fields included in your query exist and that you have specified their names correctly.
The error occurred while processing an element with a general identifier of (CFQUERY), occupying document position (14:1) to (14:41)."
oh and line 14:1 to 14:41 is this :
" <cfquery name="check" datasource="users"> "
so now i wanna know is this not doable with an ACCESS base table !?!? if not then what should i use instead, and how do i set it up ?
and from reading that can you tell what are the fieldname inside the table ?? i know two are "securitylogin" and "securitypassword" but i KNOW im missing something.
PLEASE write back, i would appriciate if ANYONE could solve this!
Thanks again,
BB
from their Auguest CF article, written by Kelly Brown under heading "simple Security"
-------
<!--- Turn On Session variables --->
<cfapplication name="AccessSecurity"
sessionmanagement="Yes"
setclientcookies="Yes"
sessiontimeout="#CreateTimeSpan(0, 2, 0, 0)#">
<!-- If not logged in, run login procedure --->
<CFIF NOT IsDefined("Session.user_id">
<CFSET message="">
<!--- If submitting login form, process it --->
<CFIF IsDefined("Form.login">
<!--- Check login and password --->
<cfquery name="check" datasource="users">
SELECT user_id
FROM users
WHERE email='#FORM.securitylogin#'
and password='#FORM.securitypassword#'
</cfquery>
<!--- If user found set session variable,
otherwise set error message --->
<CFIF check.RecordCount IS NOT 0>
<CFSET Session.user_id=check.user_id>
<CFELSE>
<CFSET message="Invalid Login.">
</CFIF>
</CFIF>
<!--- If logging in or invalid login
show login form --->
<CFIF NOT IsDefined("Form.login" or
message IS NOT "">
<html><head><title>User Login</title></head>
<body bgcolor="white">
<P align="CENTER"><B>Login</B></P>
<CFIF message IS NOT "">
<CFOUTPUT><P align="CENTER"><FONT color="red">
<B>#message#</B></font></P>
</CFOUTPUT><P>
</CFIF>
<!--- Extract the current file name from template
path and append the url parameters--->
<CFOUTPUT>
<FORM
action="#GetFileFromPath(CF_TEMPLATE_PATH)
#?#CGI.QUERY_STRING#" method="POST">
</cfoutput>
<!--- Create all passed in form variables as
hidden form fields --->
<CFIF IsDefined("Form.FieldNames">
<CFLOOP INDEX="ThisVar" list="#Form.FieldNames#">
<CFIF ThisVar IS NOT "securitylogin" AND
ThisVar IS NOT "securitypassword">
<CFOUTPUT>
<input type=hidden
name="#ThisVar#"
value="#Evaluate("Form.#ThisVar#"#">
</cfoutput>
</cfif>
</cfloop>
</cfif>
<DIV align="center">
<TABLE border="0" cellspacing="0">
<TR>
<TD align=right><B>Email</B></TD>
<TD><input name="securitylogin" size=40></TD>
</TR>
<TR>
<TD align=right><B>Password</B></TD>
<TD><input type="password"
name="securitypassword"
size=15></TD>
</TR>
</TABLE>
<P>
<input type=submit value="Login" name="login">
</FORM>
</div>
</body>
</html>
<!--- Stop the template here when logging in,
ignoring the rest of page --->
<CFABORT>
</CFIF>
<!--- If our login was okay we fall through to the
rest of the page --->
</CFIF>
-----
Now i know that according to this it needs a datasource "users" and a table called "users"
now im not sure, i've made a table using ACCESS 2000 and made teh datasource... everything connects cept i get the follwing error :
"Error Diagnostic Information
ODBC Error Code = 07001 (Wrong number of parameters)
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2.
Hint: The cause of this error is usually that your query contains a reference to a field which does not exist. You should verify that the fields included in your query exist and that you have specified their names correctly.
The error occurred while processing an element with a general identifier of (CFQUERY), occupying document position (14:1) to (14:41)."
oh and line 14:1 to 14:41 is this :
" <cfquery name="check" datasource="users"> "
so now i wanna know is this not doable with an ACCESS base table !?!? if not then what should i use instead, and how do i set it up ?
and from reading that can you tell what are the fieldname inside the table ?? i know two are "securitylogin" and "securitypassword" but i KNOW im missing something.
PLEASE write back, i would appriciate if ANYONE could solve this!
Thanks again,
BB