Click here to Skip to main content
15,916,835 members
Please Sign up or sign in to vote.
1.00/5 (6 votes)
See more:
I just want the while or for loop for checking if the wrong password is entered more than 3 times, then ask for Captcha please someone help me. I don't want to use any session or database command.
Posted
Updated 9-Aug-17 19:16pm
v2
Comments
Sergey Alexandrovich Kryukov 31-Jul-12 1:55am    
What is "ceptcha"? What is "plese"? What is "i"? What session, for goodness sake? What's the application type? Why not database?
--SA
pandya purvang 31-Jul-12 2:01am    
sorry sir spelling mistake its captcha not ceptcha and sir i just want to simple logic for looping only not database.
Please tag correct technologies and explain a bit.
Don't forget to mention what application you are developing ....
pandya purvang 31-Jul-12 2:35am    
in c# .........i just want to check if password is wrong at more then 3 attempts it will show the captcha......
pasztorpisti 31-Jul-12 7:21am    
my1, oh my god! I just imagined a job interview: the question comes from the interviewer and then the interviewee starts begging for the answer. :-)
Lets say ha passed the interview, 1st day at work, begging around for lines of codes and functions at your workmates... Not extreme programming but beggar programming. :-D

Some pseudocode:

passwordCorrect = false;
attemptCount = 0;

while ((attemptCount < 3) & (passwordCorrect == false))
{
   pwd = getPassword
   attemptCount++
   passwordCorrect = isPasswordCorrect(pwd)
}

if passwordCorrect != true
{
  displayErrorMessage
  QuitOrExitOrWhateverElseHere
}
 
Share this answer
 
Comments
nv3 31-Jul-12 3:11am    
nice :-)
what to do with loops..?

you can use a static variable to store number of attepts
and in login button click event check its value, if exeeds three show CAPTCHA..
dont forget to increment its value...
 
Share this answer
 
v2
C#
private static int attempt = 0;
protected void loginBtn_Click(object sender, EventArgs e)
    {
      attempt++;
      if(/*check password */)
      {
      //login success
      }
      else
      {  
        if(attempt>3)  
         {
         //code to display captcha
         }
      }
    }
 
Share this answer
 
v2
Comments
pandya purvang 31-Jul-12 2:32am    
okk sir thanks but what should be the code in that if(/*check password*/) condition if u will provide the code here then it should be very easy for me
Albert Holguin 31-Jul-12 13:00pm    
It's simple, read the input that the user gave you (from whatever source) then compare it against your known password. The password should probably be kept on an encrypted file somewhere.
Please check How To Block The UserName After 3 Invalid Password Attempts ??[^].
Check all the correct answers and see the last post which have good code example for you.
Thanks...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900