Password Program in ColdFusion

The Login Page

For a a username and password on the system, and then try it out on the login.cfm page, or take something from the
Access datatable I posted in the last page.

Here is the originating form and the result of the login page's form, the login_action.cfm. both posted one after another.

<FORM NAME="CFForm_1" ACTION="login_action.cfm" METHOD=POST onSubmit="return _CF_checkCFForm_1(this)">
<table border=0 bordercolor="000000" cellpadding=5 cellspacing=0>
<font face="Arial,Helvetica, sans-serif" color="FFFFFF" size="2"><b><font color="#FFFFFF">Get
Free Email !<br><br>
Email login:<br><br><font face="Arial,Helvetica, sans-serif" color="FFFFFF" size="2"><br>
<font size="2">
<INPUT TYPE="text" NAME="username" TABINDEX=3 SIZE="22" MAXLENGTH="50"><br>
<input type="hidden" name="username_required" value="You must enter your User Name">
<INPUT TYPE="password" NAME="password" TABINDEX=3 SIZE="22" MAXLENGTH="50"><br>
<input type="hidden" name="password_required" value="You must enter your Password">

<input type="SUBMIT" value="Login" name="login">

<div align="center"><a href="passwda.cfm"><font color="#FFFFFF">New
users Signup!</font></a></div>
<div align="center"><a href="forgot1.cfm"><font color="#FFFFFF">Did you forget your User Name or Password?</font></a></div>

And now the login_action page:

<cfif NOT IsDefined ('form.username')>
<cflocation url="login.cfm" addtoken="No">

<cfquery name="gilwayb" datasource="upload">
FROM passwd
WHERE USERNAME = '#FORM.username#'
AND PASSWORD = '#FORM.password#'

<CFSET Session.LoggedIn = "1">
<CFSET Session.FirstName = "#gilwayb.FirstName#">

<CFIF gilwayb.RecordCount IS 0>
<cflocation url="login.cfm" addtoken="No">
<CFSET StructClear(Session)>
<CFSET Session.LoggedIn = "1">
<cflocation url="welcome.cfm" addtoken="No">

And now the welcome.cfm page which is the "it works!" direction of the login_action page...Another really nice thing, you get a Welcome FirstName! when you enter correctly!

<CFIF NOT IsDefined("Session.loggedIn")>
<CFSET StructClear(Session)>

<H1><CENTER>WELCOME <cfoutput>#session.FIRSTNAME#</cfoutput> !</H1></CENTER>

<!-- begin application.cfm -->

What's left - yes, that application.cfm page, the page that must be in every directory with your ColdFusion pages. If you don't know how to operate one, and the program doesn't work me at [email protected], and we will be glad to work with it... Basically,on the application.cfm page should have SESSIONMANAGEMENT="YES" AND CLIENTMANAGEMENT="YES"...

Whew!!, this whole thing is definitely not as easy as an ASP database driven password program, but well, you might as well try and
use both items.

You might also like...


About the author

Julia Lynne Green United States

I have been a ColdFusion and ASP programmer for UPS in Watertown Massachusetts for the past two years, and for my own business, Julia Computer Consulting. I believe ColdFusion is the way of the...

Interested in writing for us? Find out more.


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Debuggers don't remove bugs. They only show them in slow motion.”