I have a home page in which there are links both for public and private pages. I want 
users with a password to be able to click on a private page link, login, then be 
forwarded directly to that page. It is easy enough to send them to a specific page, 
but I can't seem to "forward" them. This code takes the user back to the login form.

The code I'm using is very simple and basic (which is probably the problem). I've 
included it below. If anyone can help, I'd appreciate it. I've wasted two days of my 
life working on this.


Application.cfm:
<cfapplication name="login" clientmanagement="YES" sessionmanagement="YES" 
setclientcookies="Yes"> 

<!--- test for existence of session.logged in --->
<cfif NOT IsDefined("Session.LoggedIn")>
        <CFSET Session.LoggedIn=False>
</cfif>

<!--- if logged.in is false, send user to form --->
<CFIF Session.LoggedIn EQ FALSE>
        <cfif NOT (CGI.Path_Info EQ "/formpage.cfm") OR NOT (CGI.Path_Info is 
"/actionpage.cfm")>
        <!--- send formpage.cfm the path user was trying to get to --->
        <CFLOCATION 
url="http://localhost/isri/login/formpage.cfm?dest=#cgi.path_info#" addtoken="No">
         </cfif> 
</cfif>

<!--- if user has already logged in, let them into page --->
 <cfif Session.LoggedIn EQ True>
<CFLOCATION url="#CGI.Path_info#" addtoken="No">
</cfif>



Formpage.cfm:
<!--- login form with generic username already submitted via hidden field --->
<form action="actionpage.cfm" method="post">
<cfif ISDEFINED ("URL.dest") EQ TRUE>
<cfoutput><input type="Hidden" value="#URL.dest#" name="dest"></cfoutput></cfif>
<input type="hidden" name="name" size="30" maxlength="30" value="u"><font 
face="Verdana, Arial, Helvetica, sans-serif" size="2"><b>Password:
</b></font>
<input type="password" name="password" size="30" maxlength="30"><br>
<input type="submit" value="Log In">&nbsp;<input type="Reset">
</form>

Actionpage.cfm:
<cfquery datasource="isri" name="auth">
SELECT username, pwd
FROM login
WHERE username = '#Form.name#' AND pwd = '#form.password#'
</cfquery>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
        <title>Log In</title>
</head>
<body>
<!--- if the query produces a record send user to page they had clicked on --->
<cfif auth.RecordCount IS 1>
<CFSET Session.LoggedIn = True>
 <CFLocation url="#dest#" addtoken="No">
 <!--- if login is not acceptable --->
<cfelse>
<script language="javascript">
alert("We're sorry, but we were unable to verify either your Name or Password. Please 
try again.")
self.location = 'formpage.cfm'
</script>
</cfif>
</body>
</html>


Chris Estes
(202) 662-8536
[EMAIL PROTECTED]
http://www.isri.org
http://www.scrap.org

------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebarRsts&bodyRsts/cf_talk or send a message 
to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to