Solved

Block multiple login attempts

Posted on 2009-05-20
5
672 Views
Last Modified: 2012-05-07
Need script to block multiple login attempts after 3 tries. I have the login process set up in Coldfusion. Help.
<CFIF ISDEFINED("Form.userProvided")>
<CFSET userProvided =  #parsecfmsql(Form.userProvided)#>
<CFSET pwProvided =  #parsecfmsql(Form.pwProvided)#>
 <CFQUERY NAME="Check" datasource="datasourcename">
 SELECT *
 FROM Users 
 WHERE userProvided = '#userProvided#'
 AND pwProvided = '#pwProvided#'
 </CFQUERY>
 <CFIF CHECKADMIN.RECORDCOUNT IS 1>
  <CFSET SESSION.LoggedIn="Yes">
  <CFSET SESSION.UserId=Check.Id>
  <cflocation url="gotopage.cfm" addtoken="No">
 <CFelse>
  <script language="JavaScript">
    alert( 'Please try again.');
    self.location="backtologin.cfm";
  </script>
  </cfif>
</CFIF>

Open in new window

0
Comment
Question by:tartarus78
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 63

Accepted Solution

by:
Zvonko earned 250 total points
ID: 24434885
How about this:
<CFIF ISDEFINED("Form.userProvided")>
<CFSET userProvided =  #parsecfmsql(Form.userProvided)#>
<CFSET pwProvided =  #parsecfmsql(Form.pwProvided)#>
 <CFQUERY NAME="CHECKADMIN" datasource="datasourcename">
 SELECT *
 FROM Users 
 WHERE userProvided = '#userProvided#'
 AND pwProvided = '#pwProvided#'
 </CFQUERY>
 <CFIF CHECKADMIN.RECORDCOUNT IS 1>
  <CFSET SESSION.LogCount=0>
  <CFSET SESSION.LoggedIn="Yes">
  <CFSET SESSION.UserId=Check.Id>
  <cflocation url="gotopage.cfm" addtoken="No">
 <CFelse>
  <cfparam name="SESSION.LogCount" value="0" >
  <CFSET SESSION.LogCount=SESSION.LogCount+1>
  <cfif SESSION.LogCount GT 3 >
    <cflocation url="quitlogin.cfm" >
  </cfif>
  <script language="JavaScript">
    alert( 'Please try again.');
    self.location="backtologin.cfm";
  </script>
  </cfif>
</CFIF>

Open in new window

0
 

Author Comment

by:tartarus78
ID: 24435530
Wonderful, thanks Zvonko!!!

I changed value="0" to default="0" in CFPARAM. Any idea why the JavaScript ALERT is not working?
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 24436474
Uhps, sorry for the default.

Do you have method=post in your form tag?
I do get the alert() in my tests.

0
 

Author Comment

by:tartarus78
ID: 24442373
Yes, I do have method=post on my form tag. Very weird.
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 24444425
Look into browser html page source where you expect the alert() and look for broken html tags. Sometimes it is a simple missing closing " for the string to prevent whole script form execution.

Post here the html page source and I can check for you.

0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Print Rhino Java Array in Javascript 1 39
Rotate images for Web Page 11 28
How to pass values to HTML-5 attribute dynamically? 24 53
fillable forms on website 2 9
An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question