I've been trying for two days to get this to work. I let dreamweaver write the code for me. The username and password that I enter in is in the database. but it keeps sending to the loginfailed page that I created. It never goes the loginsucceeded page.
You might want to check you datasource in your query.
<cfquery name="dbquery" datasource="register">
SELECT username,password FROM register WHERE username='#FORM.textfield#' AND password='#FORM.textfield2#'
</cfquery>
Where you have "register" as your datasource you also have register as the table you are pulling the username and password fields from. I ran the same code on my server with a little modification make sure your table fields are correct also. Here it is:
<cfif IsDefined("FORM.textfield">
<cfset MM_redirectLoginSuccess="clientsearch.cfm">
<cfset MM_redirectLoginFailed="no.cfm">
<cfquery name="dbquery" datasource="IGNEW">
SELECT user,password FROM access WHERE user='#FORM.textfield#' AND password='#FORM.textfield2#'
</cfquery>
<cfif dbquery.RecordCount neq 0 >
<cftry>
<cflock scope="Session" timeout="30" type="Exclusive">
<cfset Session.MM_Username=FORM.textfield>
<cfset Session.MM_UserAuthorization="">
</cflock>
<cfif IsDefined("URL.accessdenied" AND false>
<cfset MM_redirectLoginSuccess=URL.accessdenied>
</cfif>
<cflocation url="#MM_redirectLoginSuccess#" addtoken="no">
<cfcatch type="Lock"><!--- code for handling timeout of cflock --->
</cfcatch>
</cftry>
</cfif>
<cflocation url="#MM_redirectLoginFailed#" addtoken="no">
This is what jumps out at me in being where your problem is:
<cfif IsDefined("URL.accessdenied" AND false>
<cfset MM_redirectLoginSuccess=URL.accessdenied>
</cfif>
Actually, in the first line, "cfif IsDefined("URL.accessdenied" AND false". What exactly is this supposed to mean? What is supposed to be "False"? Basically, you're saying "If it's defined and has no definition." I think that CF is getting confused by this statement and setting the variable and redirecting to the "Access Denied" page.
Try dropping the "AND false" or coming up with a clearer IF statement. I think if you drop the "AND false", it may work as it is.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.