Ask a Question related to Coldfusion - Getting Started, Design and Development.
-
jedale #1
Problems with User Autentication
I am trying to develop a login page for my website using a table with userID
and Password through a coldfusion interface. I used some of the code that
dreamweaver gives you to login in a user by creating a sever behavior. This
code allows me to input a username and password that I should be able to match
up to the database table. This is the opposite of what it is doing, the code
only takes my username and password and goes to the "login_failed.cfm" page.
This is the only thing that happens even if I put in a correct username and
password.
I have been working on this problem for a while and I don't know that much
about html other then getting aquainted with it for less than a month.
If anybody could help me out with this that would be great!
Here is the exact code that I have:
</html>
<cfif IsDefined("FORM.Username")>
<cfset MM_redirectLoginSuccess="eelv/act_sub.cfm">
<cfset MM_redirectLoginFailed="login_failed.cfm">
<cfquery name="MM_rsUser" datasource="cfdocexamples">
SELECT UserID,Password,Roles
FROM LoginInfo
WHERE UserID='#FORM.Username#'
AND Password='#FORM.Password#'
</cfquery>
<cfif MM_rsUser.RecordCount NEQ 0>
<cftry>
<cflock scope="Session" timeout="30" type="Exclusive">
<cfset Session.MM_Username=MM_rsUser.UserID>
<cfset Session.MM_UserAuthorization=MM_rsUser.Roles[1]>
</cflock>
<cfif IsDefined("URL.accessdenied") AND true>
<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">
<cfelse>
<cfset MM_LoginAction=CGI.SCRIPT_NAME>
<cfif CGI.QUERY_STRING NEQ "">
<cfset MM_LoginAction=MM_LoginAction & "?" & XMLFormat(CGI.QUERY_STRING)>
</cfif>
</cfif>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link href="css/bluestyles.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.style2 { font-size: 16px;
font-weight: bold;
color: #FFFFFF;
}
</style>
</head>
<body>
<div id="Header"> </div>
<div id="Image"> </div>
<!-- Editable Region -->
<div id="Content">
<p class="style2">LOG IN </p>
<p align="left" class="style2">Please log into the WEARS System </p>
<div align="right"><cfoutput>#DateFormat(Now(), "mmmm d,
yyyy")#</cfoutput></div>
<div align="right"><cfoutput>#TimeFormat(Now(), "long")#</cfoutput></div>
<p align="left" class="style2"> </p>
<p align="left" class="style2"> </p>
<p align="left" class="style2">
<form ACTION="<cfoutput>#MM_loginAction#</cfoutput>" name="FORM"
method="POST">
<table>
<tr>
<td valign="top"><span class="style2"> Username: </span></td>
<td><input size="50" maxlength=250 type="text"
name="Username">
</td>
</tr>
<tr>
<td valign="top"><strong> Password: </strong></td>
<td><input size="50" maxlength=250 type="text"
name="Password">
</td>
</tr>
</table>
<p> </p>
<p> </p>
<div align="center">
<input type="submit" name="Submit" value="Log In">
</div>
</form>
</div>
<p> </p>
<p> </p>
<p> </p>
</body>
</html>
Thanks for your time!!
Jeff
jedale Guest
-
Login and New User Problems
I'm using php for my website and I add in the insert record and then check new user to a page. Then when I go check the page in my web browser it... -
User Authentication problems
hi everyone i am using a php site and i have been trying to implement user authentication by completing the macromedia tutorial "Macromedia -... -
Windows autentication with WindowsPrinicipal
Hello, I'm using Windows Authenetication with my code below with Windows Principal. I noticed that when i use IsinRole with "BUILT\Administrator... -
Windows autentication PROBLEMS
HI I was using Windows Authentication before in my LOCALHOST with BuiltIN/Administrator(And i was getting DOMAIN\USERNAME and it was working now ... -
Forms autentication and registration page - some advices
Hi, I implement forms authentication in my application. So I have a login form. Actually I have two custom Web controls, one to login and one to... -
CFDEBUG #2
Re: Problems with User Autentication
Even though you have MM_redirectLoginSuccess set to act_sub.cfm, there is a
posssibility that this is being changed where you are checking for
url.accessdenied and assigning its value to MM_redirectLoginSuccess. So double
check ur url variables when posting.
Also your failure redirection is out of context. If you notice, you have
closed the cfif before the failure cflocation. So it should be
<cfif IsDefined("FORM.Username")>
<cfset MM_redirectLoginSuccess="eelv/act_sub.cfm">
<cfset MM_redirectLoginFailed="login_failed.cfm">
<cfquery name="MM_rsUser" datasource="cfdocexamples">
SELECT UserID,Password,Roles
FROM LoginInfo
WHERE UserID='#FORM.Username#'
AND Password='#FORM.Password#'
</cfquery>
<cfif MM_rsUser.RecordCount NEQ 0>
<cftry>
<cflock scope="Session" timeout="30" type="Exclusive">
<cfset Session.MM_Username=MM_rsUser.UserID>
<cfset Session.MM_UserAuthorization=MM_rsUser.Roles[1]>
</cflock>
<cfif IsDefined("URL.accessdenied") AND true>
<cfset MM_redirectLoginSuccess=URL.accessdenied>
</cfif>
<cflocation url="#MM_redirectLoginSuccess#" addtoken="no">
<cfcatch type="Lock">
<!--- code for handling timeout of cflock --->
</cfcatch>
</cftry>
<cfelse>
<cflocation url="#MM_redirectLoginFailed#" addtoken="no">
</cfif>
<cfelse>
<cfset MM_LoginAction=CGI.SCRIPT_NAME>
<cfif CGI.QUERY_STRING NEQ "">
<cfset MM_LoginAction=MM_LoginAction & "?" & XMLFormat(CGI.QUERY_STRING)>
</cfif>
</cfif>
CFDEBUG Guest



Reply With Quote

