Solved

Block multiple login attempts

Posted on 2009-05-20
5
671 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
  • 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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

831 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