User Guide

Table Of Contents
Implementing user security 397
Example: loginform.cfm
The loginform.cfm page consists of the following:
<H2>Please Log In</H2>
<cfoutput>
<form action="#CGI.script_name#?#CGI.query_string#" 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>
<cfelse>
<cfoutput>
<H2>Your login information is not
valid.<br>
Please Try again</H2>
</cfoutput>
<cfinclude template="loginform.cfm">
<cfabort>
Executes if the query did not return a role.
If the database is valid, this means there
was no entry matching the user ID and
password. Displays a message, followed
by the login form.
The
cfabort tag prevents processing of
any code that follows on this page.
</cfif>
</cfif>
</cfif>
</cflogin>
Ends the loginquery.Roles test code.
Ends the form entry empty value test.
Ends the form entry existence test.
Ends the
cflogin tag body.
<cfif GetAuthUser() NEQ "">
<cfoutput>
<form action="MyApp/index.cfm"
method="Post">
<input type="submit" Name="Logout"
value="Logout">
</form>
</cfoutput>
</cfif>
If a user is logged-in, displays the Logout
button.
If the user clicks the button, posts the form
to the application’s (theoretical) entry
page, index.cfm.
Application.cfc then logs out the user and
displays the login form. If the user logs in
again, ColdFusion displays index.cfm.
</cffunction>
</cfcomponent>
Ends the onRequestStart method
Ends the Application component.
Code Description