View Single Post
Old 07-13-2010, 08:52 PM   PM User | #13
TexasLegacy
New to the CF scene

 
Join Date: Jul 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
TexasLegacy is an unknown quantity at this point
A simple login, put this in your application.cfm or application.cfc page. At the top of each page set <cfif Session.LogInKeyword eq "George123"> Make up your own check pattern.

<cfapplication sessionmanagement="Yes" sessiontimeout="#createtimespan(0,0,15,0)#">

<cfparam name="LoggingOut" default="No">
<cfparam name="Session.LogInKeyword" default="none">
<cfparam name="Attempting" default="No">

<cfif LogginOut eq "Yes">
<cfset Session.LogInKeyword = "none">
<!--- This LoggingOut comes from any "Log Out" link or form --->
</cfif>

<cfinclude template="includes/PageHeader.htm">

<cfif Session.LogInKeyword eq "none">
<cfif Attempting eq "Yes"> <!--- Sent "Yes" as hidden field from Login form --->
<cfquery name="GetLogIn" datasource="[Your DSN">
select UserPwd from Users where UserID = '#UserID#'
</cfquery>

<cfif Form.UserPwd eq GetLogin.UserPwd>
<cfset Session.LogInKeyword eq "George123">
<cfelse>
<h2>Sorry, Your Login is Incorrect</h2>
</cfif>
</cfif>
<h2>You Must Login<h2>
<cfinclude template="includes/LoginForm.htm">
</cfif>

The PageHeader.htm would contain your DOCTYPE, HEAD, the LINK to your stylesheet, the BODY tag, and the banner, but NOT the navigation. That comes next:

<cfif Session.LogInKeyword eq "George">
<cfinclude template/Navigation.htm">
... (Page content etc)
</cfif>

Okay, you caught me, I save my includes as .htm (I like the color coding in HTMLkit). But ColdFusion (unlike PHP) MERGES the include first, THEN parses the code. so you includes can contain CFML and be saved as .htm and they'll work fine.

Good Luck.

~Bob in Texas

Last edited by TexasLegacy; 07-13-2010 at 08:54 PM.. Reason: Added the logout sequence
TexasLegacy is offline   Reply With Quote