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!
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