Library tutorials & articles

Password Program in ColdFusion

The Login Page

For a test...post 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">
Password:<br>
<INPUT TYPE="password" NAME="password" TABINDEX=3 SIZE="22" MAXLENGTH="50"><br>
<input type="hidden" name="password_required" value="You must enter your Password">

</font>
<center>
<input type="SUBMIT" value="Login" name="login">

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

And now the login_action page:

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

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

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

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

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)>
<CFLOCATION URL="http://www.dautolink.com/login.cfm">
</CFIF>

<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 still...email me at juliag@shore.net, 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.

Comments

  1. 01 Jan 1999 at 00:00

    This thread is for discussions of Password Program in ColdFusion.

Leave a comment

Sign in or Join us (it's free).

Julia Lynne Green 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 fut...

Related podcasts

  • Crawlable Flash, Concurrent Python, Smart Robots.txt and more

    Mixed topics today Adobe works with Google, Yahoo and others to make Flash apps crawlable. Reddit.com open sources their codebase "Smart" robots.txt files - do you use them? Bruce Eckel article on concurrent Python with Twisted Railo - open source ColdFusion Cognifty - new PHP framework...

We'd love to hear what you think! Submit ideas or give us feedback