php - How to exit the application on 3 wrong attempts -


i have made login page no. of attempts checked. problem right locks user keeps counter no. of attempts increasing. want exit stop counter increment. please help!

<html> <head><title>meeting room application</title> <script type="text/javascript">  function validation()  {     var uname=document.forms["login"]["txtuid"].value;     var pwd=document.forms["login"]["txtpwd"].value;     if((uname==null || uname=="") && (pwd==null || pwd==""))     {         alert("please fill details");         return false;     }     if(uname==null || uname=="")     {         alert("please enter username");         return false;     }     if(pwd==null || pwd=="")     {         alert("please enter password");         return false;      }     if(noofattempt>=3)         return false;    }    </script>    </head>    <body background="a6.jpg">    <?php           session_start();           if(isset($_session['loginattempt']))           $noofattempt=(int) $_session['loginattempt'];           else           $noofattempt=0;      ?>       <table align="center" cellpadding="5" cellspacing="5">       <tr><td colspan="2" align="center"><img src="logo.jpg" width="275px;">     </td></tr>       <tr><th align="center" colspan="2">kindly provide login details</th</tr>      <form method="post" name="login" action="checkdb.php" onsubmit="return validation()" >      <tr><td align="right"><b>userid : </td><td><input type="text" name="txtuid" placeholder="user"></td></tr>       <tr><td align="right"><b>password : </td><td><input type="password" name="txtpwd" placeholder="*****"></td></tr>   <tr><td></td>   <td><font color="red">   <?php        if(isset($_session['error']))       {              echo $_session['error']."<br>";              echo "no of attempt ". $noofattempt;       }         if($noofattempt>=3)                 echo "<br>your account has been locked..contact admin";        ?> </font></td></tr>        <tr><td colspan="2" align="center"><input type="submit" value="sign in">        <input type="reset" value="reset"><input type="hidden" name='noofattempt' value= <?php echo $noofattempt;  ?> /></td>          </tr>          </form>          </div>          </div>          </table>          </body>          </html> 

you not retrieving hidden form value noofattempt in validation() function.

var noofattempt=document.forms["login"]["noofattempt"].value; 

note stop user accidentally submitting form additional times after limit has been reached, previous commenter said, can overridden trying so, or possibly having javascript disabled. limit should enforced somewhere else in php code.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -