Forums
This topic is locked
User Login Server Behavior
23 Apr 2007 17:28:06 mike o posted:
I'm trying to write a very simple user login but can't get it to work (does not direct users to login successful screen). Here is the code. Help!!!!<cfif IsDefined("FORM.user"
<cfset MM_redirectLoginSuccess="Test.cfm">
<cfset MM_redirectLoginFailed="main.cfm">
<cfquery name="MM_rsUser" datasource="ciforum">
SELECT User,Password FROM Login WHERE User='#FORM.user#' AND Password='#FORM.pass#'</cfquery>
<cfif MM_rsUser.RecordCount NEQ 0>
<cftry>
<cflock scope="Session" timeout="30" type="Exclusive">
<cfset Session.MM_Username=FORM.user>
<cfset Session.MM_UserAuthorization="">
</cflock>
<cfif IsDefined("URL.accessdenied"
<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><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="POST" action="<cfoutput>#MM_loginAction#</cfoutput>">
<table width="438" border="1" cellspacing="0" cellpadding="2">
<tr>
<th scope="col"><div align="left">Username</div></th>
<th scope="col"><div align="left">
<input name="user" type="text" id="user" />
</div></th>
</tr>
<tr>
<td><div align="left">Password</div></td>
<td><input name="pass" type="text" id="pass" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Test" /></td>
</tr>
</table>
</form>
</body>
</html>