Coldfusion Login Script
Here i am going to show you how to make a login script that will check users against a database for the user name and password.
First of all we will need to make a login form, this is just going to be a basic form with a user name field, password field and a login button.
<table cellspacing="0" cellpadding="0" width="300" align="center" border="0">
<tbody>
<tr>
<td colspan="2">
<div class="style2" align="center"><strong>Login</strong></div>
</td>
</tr>
<tr>
<td>Username</td>
<td><input id="Username" name="Username" type="text" /></td>
</tr>
<tr>
<td>Password</td>
<td><input id="Password" type="password" name="Password" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit" /></td>
</tr>
</tbody>
</table>
</form>
Now we have the form we need check the form and see if the user exists and that there password is correct. If the details are not correct they will be sent back to the login page.
If the details are correct then we will set there user name as a session variable so that it can be used in the site, and we will send them to the secure page.
As you can see this is a very basic script, but it is all you need to get started. I will soon be covering how to store encrypted passwords in your database and how to add roles to the users.

Once again...Many thanks.
The Code in qustion:
<cfif IsDefined("FORM.username")>
<cfset MM_redirectLoginSuccess="Client_contacts.cfm">
<cfset MM_redirectLoginFailed="login_fail.cfm">
<cfquery name="MM_rsUser" datasource="intranet" username="robinford" password="Combat01">
SELECT username,password FROM users WHERE username=<cfqueryparam value="#FORM.username#" cfsqltype="cf_sql_clob" maxlength="15"> AND password=<cfqueryparam value="#FORM.password#" cfsqltype="cf_sql_clob" maxlength="9">
</cfquery>
<cfif MM_rsUser.RecordCount NEQ 0>
<cftry>
<cflock scope="Session" timeout="30" type="Exclusive">
<cfset Session.MM_Username=FORM.username>
<cfset Session.MM_UserAuthorization="">
</cflock>
<cfif IsDefined("URL.accessdenied") AND false>
<cfset MM_redirectLoginSuccess=URL.accessdenied>
</cfif>
<cflocation url="#MM_redirectLoginSuccess#" addtoken="no">
<cfcatch type="Lock"><!--- code for handling timeout of cflock --->
</cfcatch>
</cftry>
</cfif>
<cflocation url="#MM_redirectLoginFailed#" addtoken="no">
<cfelse>
<cfset MM_LoginAction=CGI.SCRIPT_NAME>
<cfif CGI.QUERY_STRING NEQ "">
<cfset MM_LoginAction=MM_LoginAction & "?" & XMLFormat(CGI.QUERY_STRING)>
</cfif>
And thats it.
I understand that there are a couple of issues with this between CF 8 and Dreamweaver CS3 and am still researching as to what solutions may be available.
Many many thanks.
Rob.
http://www.nikeairmaxtrainers.co.uk/nike-air-max-shoes-nike-air-max-90-c-39_52.html" target="_blank">http://www.nikeairmaxtrainers.co.uk/nike-air-max-s...
http://www.nikeairmaxtrainers.co.uk/nike-air-max-shoes-nike-air-max-95-c-39_61.html" target="_blank">http://www.nikeairmaxtrainers.co.uk/nike-air-max-s...
http://www.nikeairmaxtrainers.co.uk/nike-air-max-shoes-c-39.html
http://www.nikeairmaxtrainers.co.uk/nike-air-max-shoes-nike-air-max-97-c-39_80.html" target="_blank">http://www.nikeairmaxtrainers.co.uk/nike-air-max-s...
http://www.nikeairmaxtrainers.co.uk/nike-air-max-shoes-nike-air-max-95-c-39_61.html" target="_blank">http://www.nikeairmaxtrainers.co.uk/nike-air-max-s...
http://www.nikeairmaxtrainers.co.uk/nike-air-max-shoes-nike-air-max-ltd-c-39_42.html" target="_blank">http://www.nikeairmaxtrainers.co.uk/nike-air-max-s...
http://www.nikeairmaxtrainers.co.uk/nike-air-max-shoes-nike-air-max-ltd-ii-c-39_84.html" target="_blank">http://www.nikeairmaxtrainers.co.uk/nike-air-max-s...
http://www.nikeairmaxtrainers.co.uk/nike-air-max-shoes-nike-air-max-bw-c-39_65.html
http://www.nikeairmaxtrainers.co.uk/nike-shox-shoes-nike-shox-nz-c-1_16.html" target="_blank">http://www.nikeairmaxtrainers.co.uk/nike-shox-shoe...
http://www.nikeairmaxtrainers.co.uk/nike-shox-shoes-nike-shox-r4-c-1_2.html" target="_blank">http://www.nikeairmaxtrainers.co.uk/nike-shox-shoe...
http://www.nikeairmaxtrainers.co.uk/nike-air-max-shoes-nike-air-presto-c-39_77.html" target="_blank">http://www.nikeairmaxtrainers.co.uk/nike-air-max-s...
http://www.myairmax.com/
http://www.myairmax.com/nike-airmax-shoes-nike-airmax-180-c-1_244.html
http://www.myairmax.com/nike-airmax-shoes-nike-airmax-360-c-1_307.html
http://www.myairmax.com/nike-airmax-shoes-nike-airmax-87-c-1_255.html
http://www.myairmax.com/nike-airmax-shoes-nike-airmax-90-c-1_3.html" target="_blank">http://www.myairmax.com/nike-airmax-shoes-nike-air...
http://www.myairmax.com/nike-airmax-shoes-nike-airmax-95-c-1_2.html" target="_blank">http://www.myairmax.com/nike-airmax-shoes-nike-air...
http://www.myairmax.com/nike-airmax-shoes-nike-airmax-97-c-1_306.html
http://www.myairmax.com/nike-airmax-shoes-nike-air-max-ltd-c-1_117.html" target="_blank">http://www.myairmax.com/nike-airmax-shoes-nike-air...