Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem with CFLOGIN in my Application.cfm

0 views
Skip to first unread message

BCPower001

unread,
Apr 23, 2003, 12:44:55 PM4/23/03
to
I have the attached code in a file called ForceUserLogin.cfm (right from the book CF Web App Const.) <cfincluded at the top of my Application.cfm file. The Application.cfm file is in the application root directory.

QUESTION 1:
When I try to access a file in my application, I get the login prompt that I should get. When I login, I just get a blank page (ForceUserLogin.cfm). Shouldn't I be sent to the page I originally tried to view?

How do I write that? The book makes no mention of it and it leaves me clueless.

<cflogin>
<cfif NOT (IsDefined("FORM.Username") AND IsDefined("FORM.Password"))>
<cfinclude template="UserLoginForm.cfm">
<cfabort>

<cfelse>
<cfquery name="GetUser" datasource="Insurance DB">
SELECT Username, Password, UserRole
FROM Users
WHERE Username = '#FORM.Username#'
AND Password = '#FORM.Password#'
</cfquery>

<cfif GetUser.RecordCount EQ 1>
<cfloginuser name="#GetUser.Username#" password="#GetUser.Password#" roles="#GetUser.UserRole#">
<cfelse>
<cfinclude template="UserLoginForm_RETRY.cfm">
<cfabort>
</cfif>
</cfif>
</cflogin>

Thank you for your continued support!

TRBishop

unread,
Apr 24, 2003, 7:09:45 AM4/24/03
to
BCPower001-

What you have as the action page for your login form will determine where you go after clicking the login/submit button.

Of course the Appliction.cfm file runs again, and logs you into the ColdFusion security context, but it doesn't send you anywhere. The code below (taken from my ColdFusion MX documentation) is for a login form that will automatically capture the address of the page and go there on submit.

<cfcset url="http://" & "#cgi.server_name#" & ":" & #cgi.server_port#" & "#cgi.script_name#">
<cfif cgi.query_string IS NOT " ">
<cfset url=url+ "?#cgi.query_string#">
</cfif>
<h2>Please Log In</h2>
<cfoutput>
<form action ="#url#" method="post">
<table>
<tr>
<td>username</td>
<td><input type="text" name="j_username"></td>
</tr>
<tr>
<td>password</td>
<td><input type="password" name="j_password"></td>
</tr>
</table>
<br>
<input type="submit" value="log in">
</form>
</cfoutput>

I had issues using a variable named 'url' and had to rename it. Other than that it worked fine.
Hope this helps!

Tom


0 new messages