I have this form / login application and i'm trying to attach my database,to replace the static username and password entered its a 2 page - A forum page ( i called it login.cfm ) and the result page which i called it index.cfm , here is the code for the index.cfm before changes which works perfect :
----------------------------------------------------------
<cfset goodLogin = false>
<cfif isDefined("form.username" and len(trim(form.username)) and
isDefined("form.password" and len(trim(form.password))>
<cfif not compare(trim(form.username),"user" and not compare(trim(form.password),"user">
<cfloginuser name="#form.username#" password="#trim(form.password)#" roles="add">
<cfset goodLogin=true>
<cfelseif not compare(trim(form.username),"admin" and not compare(trim(form.password),"admin">
<cfloginuser name="#form.username#" password="#form.password#" roles="edit,add,delete">
<cfset goodLogin=true>
</cfif>
</cfif>
<cfif not goodLogin>
<!--- Display login form --->
<cfinclude template="login.cfm">
<cfabort>
</cfif>
</cflogin>
<!--- my outputs if the login succesfully --->
<cfoutput>
<p>
<b>Welcome, #GetAuthUser()#!</b>
</p> </cfoutput>
<cfif isUserInRole("add">
<a href="security/index.cfm">Add Content</a>
</cfif>
<cfif isUserInRole("edit">
~ <a href="security/index.cfm">Edit Content</a>
</cfif>
<cfif isUserInRole("delete">
~ <a href="security/index.cfm">Delete Content</a>
</cfif>
----------------------------------------------------------
now here is what i've done, which its not validating the user name and password from the DB ..
-----------------------------------------------------------
<cfset goodLogin = false>
<cfif isDefined("form.username" and len(trim(form.username)) and
isDefined("form.password" and len(trim(form.password))>
<cfquery name="qValidLogin" datasource="stock">
SELECT *
FROM tblMember </cfquery>
<cfif not compare(trim(form.username),"#qValidLogin.MemberName#" and not compare(trim(form.password),"#qValidLogin.Password#">
<cfloginuser name="#form.username#" password="#trim(form.password)#" roles="#qValidlogin.role#">
<cfset goodLogin=true>
<!---
i deleted this extra cfloginuser
<cfelseif not compare(trim(form.username),"admin" and not compare(trim(form.password),"admin">
<cfloginuser name="#form.username#" password="#form.password#" roles="edit,add,delete">
<cfset goodLogin=true>
--->
</cfif>
</cfif>
<cfif not goodLogin>
<!--- Display login form --->
<cfinclude template="login.cfm">
<cfabort>
</cfif>
</cflogin>
<!--- my outputs if the login succesfully --->
<cfoutput>
<p>
<b>Welcome, #GetAuthUser()#!</b>
</p> </cfoutput>
<cfif isUserInRole("add"> <!--- the role is written in the role feild in my database --->
<a href="security/index.cfm">Add Content</a>
</cfif>
<cfif isUserInRole("edit">
~ <a href="security/index.cfm">Edit Content</a>
</cfif>
<cfif isUserInRole("delete">
~ <a href="security/index.cfm">Delete Content</a>
</cfif>
---------------------------------------------------------------
the good news i'm not getting any errors, but when i login, it keep me at the login screen, as if i entered the wrong user name and password, i know that the database part is working, cause when i mispell the form feild on purpose (eg, "#qValidLogin.MemberNameeee#" ) i get the an error saying (Element MEMBERNAMEEEE is undefined in QVALIDLOGIN.)
i have a feeling its something simple but i can't figure it out,
I really appreciat your time and help so far
Max
----------------------------------------------------------
<cfset goodLogin = false>
<cfif isDefined("form.username" and len(trim(form.username)) and
isDefined("form.password" and len(trim(form.password))>
<cfif not compare(trim(form.username),"user" and not compare(trim(form.password),"user">
<cfloginuser name="#form.username#" password="#trim(form.password)#" roles="add">
<cfset goodLogin=true>
<cfelseif not compare(trim(form.username),"admin" and not compare(trim(form.password),"admin">
<cfloginuser name="#form.username#" password="#form.password#" roles="edit,add,delete">
<cfset goodLogin=true>
</cfif>
</cfif>
<cfif not goodLogin>
<!--- Display login form --->
<cfinclude template="login.cfm">
<cfabort>
</cfif>
</cflogin>
<!--- my outputs if the login succesfully --->
<cfoutput>
<p>
<b>Welcome, #GetAuthUser()#!</b>
</p> </cfoutput>
<cfif isUserInRole("add">
<a href="security/index.cfm">Add Content</a>
</cfif>
<cfif isUserInRole("edit">
~ <a href="security/index.cfm">Edit Content</a>
</cfif>
<cfif isUserInRole("delete">
~ <a href="security/index.cfm">Delete Content</a>
</cfif>
----------------------------------------------------------
now here is what i've done, which its not validating the user name and password from the DB ..
-----------------------------------------------------------
<cfset goodLogin = false>
<cfif isDefined("form.username" and len(trim(form.username)) and
isDefined("form.password" and len(trim(form.password))>
<cfquery name="qValidLogin" datasource="stock">
SELECT *
FROM tblMember </cfquery>
<cfif not compare(trim(form.username),"#qValidLogin.MemberName#" and not compare(trim(form.password),"#qValidLogin.Password#">
<cfloginuser name="#form.username#" password="#trim(form.password)#" roles="#qValidlogin.role#">
<cfset goodLogin=true>
<!---
i deleted this extra cfloginuser
<cfelseif not compare(trim(form.username),"admin" and not compare(trim(form.password),"admin">
<cfloginuser name="#form.username#" password="#form.password#" roles="edit,add,delete">
<cfset goodLogin=true>
--->
</cfif>
</cfif>
<cfif not goodLogin>
<!--- Display login form --->
<cfinclude template="login.cfm">
<cfabort>
</cfif>
</cflogin>
<!--- my outputs if the login succesfully --->
<cfoutput>
<p>
<b>Welcome, #GetAuthUser()#!</b>
</p> </cfoutput>
<cfif isUserInRole("add"> <!--- the role is written in the role feild in my database --->
<a href="security/index.cfm">Add Content</a>
</cfif>
<cfif isUserInRole("edit">
~ <a href="security/index.cfm">Edit Content</a>
</cfif>
<cfif isUserInRole("delete">
~ <a href="security/index.cfm">Delete Content</a>
</cfif>
---------------------------------------------------------------
the good news i'm not getting any errors, but when i login, it keep me at the login screen, as if i entered the wrong user name and password, i know that the database part is working, cause when i mispell the form feild on purpose (eg, "#qValidLogin.MemberNameeee#" ) i get the an error saying (Element MEMBERNAMEEEE is undefined in QVALIDLOGIN.)
i have a feeling its something simple but i can't figure it out,
I really appreciat your time and help so far
Max