Hello.
I'm using this log in form for my website but went a user types in the wrong
username or password, I would like to display an error message "Sorry...wrong
username" or "Sorry...wrong password". As of now this form, if wrong, returns
back to loginform.cfm.
I just think it would be nice to tell the visitors what went wrong. (Wrong
username, password, or both).
Thanks for HELP!
Barry
LoginForm
<cfif isDefined("FORM.UserLogin")>
<cfinclude template="LoginCheck.cfm">
</cfif>
<cfform action="#CGI.script_name#?#CGI.query_string#" name="LoginForm"
method="post">
<!--- Make the UserLogin and UserPassword fields required --->
<input type="hidden" name="userLogin_required">
<input type="hidden" name="userPassword_required">
<!--- Use an HTML table for simple formatting --->
<table>
<tr>
<td>Username:</td>
<td>
<!--- Text field for "User Name" --->
<cfinput
type="text"
name="userLogin"
size="20"
value=""
maxlength="100"
required="Yes"
message="Please type your Username first.">
</td>
</tr><tr>
<td>Password:</td>
<td>
<!--- Text field for Password --->
<cfinput
type="password"
name="userPassword"
size="12"
value=""
maxlength="100"
required="Yes"
message="Please type your Password first.">
<!--- Submit Button that reads "Enter" --->
<input type="Submit"
value="Enter"
title="Enter">
</td>
</tr>
</table>
</cfform>
Logincheck.cfm
<!--- Make sure we have Login name and Password --->
<cfparam name="FORM.userLogin" type="string">
<cfparam name="FORM.userPassword" type="string">
<!--- Find record with this Username/Password --->
<!--- If no rows returned, password not valid --->
<cfquery name="getUser" datasource="#APPLICATION.dataSource#">
SELECT *
FROM Contacts
WHERE UserLogin = '#FORM.UserLogin#'
AND UserPassword = '#FORM.UserPassword#'
</cfquery>
<!--- If the username and password are correct --->
<cfif getUser.recordCount eq 1>
<!--- Remember users logged-in status, plus --->
<!--- ContactID and First Name, in structure --->
<cfset SESSION.auth = structNew()>
<cfset SESSION.auth.isLoggedIn = "Yes">
<cfset SESSION.auth.contactID = getUser.contactID>
<cfset SESSION.auth.firstName = getUser.firstName>
<cfset SESSION.auth.userlevel = getUser.userlevel>
<!--- Now that user is logged in, send them --->
<!--- to whatever page makes sense to start --->
<!--- This code below will remember the users last page.--->
<cflocation url="#CGI.script_name#?#CGI.query_string#">
</cfif>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know
on the House of Fusion mailing lists
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:324827
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4