Wednesday, July 16, 2008

CaSe SensitiVe password logins! in COLDFUSION

This tutorial will show you how to check your users that are logging in to your application for Case SenSitIVe passwords.
The first thing you need is the form that asks your users to log in, we'll call this page "login.cfm":
<form action="login_process.cfm" method="post">
Username: <input type="text" name="user_name" value=""><BR>
Password: <input type="password" name="pass_word" value=""><BR>
<input type="submit" name="login_user" value="Log In"><BR>
</form>

Now create the page that will log the user is, we'll call this page "login_process.cfm".
<cfquery name="qVerify" datasource="YourDSN">
SELECT ID, username, password
FROM Members
WHERE password = '#pass_word#'
AND username = '#user_name#'
</cfquery>


<!--- ok now check for the case sensative --->
<cfset comparison = Compare(FORM.pass_word, qVerify.password)>

<!--- see what to do --->
<cfif comparison eq 0>
<!--- User is good, log in and redirect --->
<cfelse>
<!--- user did not supply a valid CAsE sensative password, alert and ask to login again! --->
</cfif>
Ok, the location that actually checks for the CaseSenSitive format is the line:
<!--- ok now check for the case sensative --->
<cfset comparison = Compare(FORM.pass_word, qVerify.password)>
That's it, you can now implement another layer of security by ensuring that your users are using their information correctly..

No comments: