Reply to topic
Need CF GURU to Make me feel like an idiot......
yobri


Joined: 31 Jan 2007
Posts: 4
Reply with quote
Having trouble with this CF code - I'm not getting a connection I don't think between my datasource and the cfm page. The error is in red the code follows below in blue. I know it's an easy fix I'm just stupid I guess. I am looking for someone to show me where I'm an idiot. hms.com has created the DNS for me to the maxbmax datasource. I want to access login information in the table userlogin in a SQL table already created.

It errors out at line 18 and tells me this:

You must pass the tablename and datasource name to this custom tag.

[color=red]The error occurred in C:\websites\108230gn6\docs\login.cfm: line 18

16 :
17 : <cfif Not IsDefined("attributes.userlogin") OR Not IsDefined("attributes.maxbmax")>
18 : <cfabort showerror="You must pass the tablename and datasource name to this custom tag.">
19 : </cfif>
20 :
[/color]


CODE for login.cfm page
<!---
CF_cascadianlogin (CascadianLogin) - A Custom ColdFusion tag by Summer S. Wilson
Last Updated: July 14, 2004
Version: 3.0

Minimum Code to Call This Tag
should be added to the top of each page that needs to be login protected:

<cf_cascadianlogin
tablename="tablename"
datasourcename="datasourcename"
>

See cascadianlogin_readme.txt for full options list
--->

<cfif Not IsDefined("attributes.userlogin") OR Not IsDefined("attributes.maxbmax")>
<cfabort showerror="You must pass the tablename and datasource name to this custom tag.">
</cfif>

<cfparam name="attributes.fieldlist" default="userID,firstname,lastname,email">
<cfparam name="attributes.logoutreturn" default="index.cfm">
<cfparam name="attributes.introtext" default="Please enter your username and password. Entries ARE case sensitive!">
<cfparam name="attributes.errortext" default="Invalid Username/Password Combination, please try again.</strong> Remember your username and password are case sensitive!">
<cfparam name="attributes.stylesheet" default="">
<cfparam name="attributes.backgroundcolor" default="">
<cfparam name="attributes.textcolor" default="">
<cfparam name="attributes.usernametext" default="Username">
<cfparam name="attributes.usernamefield" default="username">
<cfparam name="attributes.usernamesize" default="15">
<cfparam name="attributes.usernamemaxlength" default="15">
<cfparam name="attributes.passwordtext" default="Password">
<cfparam name="attributes.passwordfield" default="password">
<cfparam name="attributes.passwordsize" default="15">
<cfparam name="attributes.passwordmaxlength" default="15">
<cfparam name="attributes.showcredit" default="1">
<cfparam name="attributes.pagetitle" default="You Must Log In">
<cfparam name="attributes.logo" default="">
<cfparam name="attributes.loggedin" default="loggedin">

<!--- This ensures that the calling template gets returned all variables it
was passed. --->
<cfset FINAL_SCRIPT_NAME = cgi.Script_Name & "?" & cgi.query_string>

<!--- Processes logouts. To call use login.cfm?action=logout --->
<cfif (IsDefined("Action") and Action IS "logout" and IsDefined("session.#Trim(attributes.loggedin)#"))>
<!--- Actual logging out --->
<cflock timeout="30" name="Clear_session" type="exclusive">
<cfset StructClear(session)>
</cflock>

<cflocation url="#attributes.logoutreturn#" addtoken="No">
<cfabort>

<!--- Begin main login test --->
<cfelse>
<CFIF (NOT IsDefined("session.#Trim(attributes.loggedin)#")) OR (IsDefined("UserValue"))>
<!--- Check to see if user is logged into system --->
<CFIF (IsDefined("UserValue"))>
<!--- Have already gotten name and password --->
<!--- Pulls the info from the user tables that will be used for setting
session variables. Add fields as needed, being sure to all add
matching session sets below. --->
<CFQUERY datasource="#attributes.datasourcename#" name="login">
SELECT #attributes.fieldlist#
FROM #attributes.tablename#
WHERE #attributes.usernamefield# = '#uservalue#'
AND #attributes.passwordfield# = '#password#'
</CFQUERY>

<!--- Reprompts for login, it was invalid --->
<CFIF login.RecordCount IS "0">
<CFPARAM name="UserValue" default="">
<cfoutput>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>#attributes.pagetitle#</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<cfif attributes.stylesheet NEQ "">
<link rel="stylesheet" href="#attributes.stylesheet#" type="text/css">
<cfelseif attributes.backgroundcolor NEQ "" OR attributes.textcolor NEQ "">
<style type="text/css">
BODY {
<cfif attributes.backgroundcolor NEQ "">
background-color: ###attributes.backgroundcolor#;
</cfif>
<cfif attributes.textcolor NEQ "">
color: ###attributes.textcolor#;
</cfif>
}
</style>
</cfif>
</head>

<body>
<p id="pagetitle"><cfif attributes.logo NEQ ""><img src="#attributes.logo#"></cfif>#attributes.pagetitle#</p>
<p id="errortext">#attributes.errortext#</p>
<CFFORM action="#FINAL_SCRIPT_NAME#" name="SecureForm" method="POST">
<table border="0" cellspacing="5" cellpadding="5" align="center" class="logintable">
<tr valign="middle">
<td id="requiredfield">#attributes.usernametext#:</td>
<td><cfinput type="text" name="uservalue" size="#attributes.usernamesize#" maxlength="#attributes.usernamemaxlength#" value="#UserValue#" required="yes" message="You must enter your #lcase(attributes.usernametext)#"></td>
</tr>
<tr valign="middle">
<td id="requiredfield">#attributes.passwordtext#:</td>
<td><cfinput type="password" name="password" size="#attributes.passwordsize#" maxlength="#attributes.passwordmaxlength#" required="yes" message="You must enter your #lcase(attributes.passwordtext)#"></td>
</tr>
<tr valign="middle">
<td colspan="2" align="center" valign="top"><input id="submit" type="submit" name="submit" value="Login"></td>
</tr>
</table>
<cfif attributes.showcredit EQ 1>
<p id="creditline">Login powered by <a href="http://eclectic-designs.com/cascadianlogin.php" target="_blank">CascadianLogin</a> from <a href="http://eclectic-designs.com" target="_blank">Eclectic Designs</a></p>
</cfif>
</cfform>
</body>
</html>
</cfoutput>
<cfabort>
</CFIF>

<!--- User has been validated. Log them in and send them on their way. --->

<!--- if we have a lastlogin field, update it --->
<cfif IsDefined("attributes.lastloginfield") AND FindNoCase("join", attributes.tablename) EQ 0>
<cfquery datasource="#attributes.datasourcename#">
UPDATE #attributes.tablename#
SET #attributes.lastloginfield# = '#DateFormat(now(), "yyyy-mm-dd")#'
WHERE #attributes.usernamefield# = '#uservalue#'
AND #attributes.passwordfield# = '#password#'
</cfquery>
</cfif>

<!--- Always lock things when you are setting session variables.
To add additional variables pulled from the login query,
Just use the format of <cfset session.fieldname = login.fieldname> --->
<cflock TimeOut="30" type="exclusive" scope="session">
<CFSET "session.#Trim(attributes.loggedin)#" = "yes">

<cfloop list="#attributes.fieldlist#" index="thisfieldname">
<cfset value = Evaluate("login.#Trim(thisfieldname)#")>
<cfset variablename = "session.#Trim(thisfieldname)#">
<CFSET "#variablename#" = value>
</cfloop>
</cflock>

<cflocation url="#FINAL_SCRIPT_NAME#" addtoken="No">

<CFELSE>
<!--- Prompt user for name and password HTML can be edited
as desired, but be sure to leave in the uservalue and password fields! --->
<CFPARAM name="UserValue" default="">
<cfoutput>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>#attributes.pagetitle#</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<cfif attributes.stylesheet NEQ "">
<link rel="stylesheet" href="#attributes.stylesheet#" type="text/css">
<cfelseif attributes.backgroundcolor NEQ "" OR attributes.textcolor NEQ "">
<style type="text/css">
BODY {
<cfif attributes.backgroundcolor NEQ "">
background-color: ###attributes.backgroundcolor#;
</cfif>
<cfif attributes.textcolor NEQ "">
color: ###attributes.textcolor#;
</cfif>
}
</style>
</cfif>
</head>

<body>
<CFFORM action="#FINAL_SCRIPT_NAME#" name="SecureForm" method="POST">
<p id="pagetitle"><cfif attributes.logo NEQ ""><img src="#attributes.logo#"></cfif>#attributes.pagetitle#</p>
<p id="introtext">#attributes.introtext#</p>
<table border="0" cellspacing="5" cellpadding="5" align="center" class="logintable">
<tr valign="middle">
<td id="requiredfield">#attributes.usernametext#:</td>
<td><cfinput type="text" name="uservalue" size="#attributes.usernamesize#" maxlength="#attributes.usernamemaxlength#" value="#UserValue#" required="yes" message="You must enter your #lcase(attributes.usernametext)#"></td>
</tr>
<tr valign="middle">
<td id="requiredfield">#attributes.passwordtext#:</td>
<td><cfinput type="password" name="password" size="#attributes.passwordsize#" maxlength="#attributes.passwordmaxlength#" required="yes" message="You must enter your #lcase(attributes.passwordtext)#"></td>
</tr>
<tr valign="middle">
<td colspan="2" align="center" valign="top"><input type="submit" id="submit" name="submit" value="Login"></td>
</tr>
</table>
<cfif attributes.showcredit EQ 1>
<p id="creditline">Login powered by <a href="http://eclectic-designs.com/cascadianlogin.php" target="_blank">CascadianLogin</a> from <a href="http://eclectic-designs.com" target="_blank">Eclectic Designs</a></p>
</cfif>
</cfform>
</body>
</html>
</cfoutput>
<cfabort>
</CFIF>
</CFIF>
</cfif>
Shaji


Joined: 21 Feb 2005
Posts: 83
Reply with quote
Hi,

If u said 'hms.com has created the DNS for u to the maxbmax datasource and the table userlogin in a SQL table already created. '

You would call this tag called cf_cascadianlogin.. It should be added to the top of each page for your secure area..

<cf_cascadianlogin
tablename="userlogin"
datasourcename="maxbmax">
thanks
yobri


Joined: 31 Jan 2007
Posts: 4
Reply with quote
got it, it works perfectly thank you.
Need CF GURU to Make me feel like an idiot......
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic