atck Posted November 23, 2006 Share Posted November 23, 2006 i have designed a penpal page with few columns using mysql and php. users need to login to the penpal page to access the db. i want to limit how many times they can try if they forget their password. what is the easist way to do this ...? via my sql or php ? i need just a guidance.thanks :) Quote Link to comment https://forums.phpfreaks.com/topic/28218-login-security-php/ Share on other sites More sharing options...
alpine Posted November 23, 2006 Share Posted November 23, 2006 add attempts in a session and/or in a mysql table logging all ongoing attempts. Quote Link to comment https://forums.phpfreaks.com/topic/28218-login-security-php/#findComment-129072 Share on other sites More sharing options...
atck Posted November 24, 2006 Author Share Posted November 24, 2006 can you give coding about this problum to i soft? Quote Link to comment https://forums.phpfreaks.com/topic/28218-login-security-php/#findComment-129391 Share on other sites More sharing options...
mansuang Posted November 24, 2006 Share Posted November 24, 2006 Here is some guideline for session.[code]if($loged_in==true){ //login script}else{ if($_SESSION['attempt']>$allow_attempt){ //some error }else{ $_SESSION['attempt']++; }}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/28218-login-security-php/#findComment-129428 Share on other sites More sharing options...
atck Posted November 24, 2006 Author Share Posted November 24, 2006 correct this code plz..[attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/28218-login-security-php/#findComment-129449 Share on other sites More sharing options...
atck Posted November 24, 2006 Author Share Posted November 24, 2006 correct this code[code]<div id="SignIn"> <form method="post" action="web.php?insert=ok"> <table width="350" border="0" bgcolor="#000077"> <tr> <td colspan="2" style="font:bold"> <font color="#DDDDDD" style="font:large">web</font> </td> </tr> </table> <table width="350" border="0" class="alphabox"> <tr> <td width="161" height="35">User Name: </td> <td width="253" height="35"> <input type="text" name="username" /> </td> </tr> <tr> <td height="36" width="161">Password: </td> <td width="253" height="36"> <input type="password" name="password" /> </td> </tr> <tr> <td colspan="2"> <input type="Submit" name="Submit" value=" Login " width="60"> </td> </tr> </table> <table width="350" border="0"> <tr> <td colspan="3"> <a href="pwd4got.php"><font size="2"> Forgot Password? Click here for assistance </font> </a> </td> </tr> </table> </form></div>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/28218-login-security-php/#findComment-129453 Share on other sites More sharing options...
mansuang Posted November 24, 2006 Share Posted November 24, 2006 [code]<?php//start sessionsession_start();//define some variables$username = "demo";$password = "password";$allow_attempt = 3;//check attempt time(s)if(isset($_SESSION['attempt']) && $_SESSION['attempt']>$allow_attempt){ echo "you tried more than $allow_attempt times !"; exit;}//check if user submit formif(isset($_POST['Submit'])){ //firstly, assume username & password are incorrect $loged_in = false; //check username & password if($_POST['username']==$username && $_POST['password']==$password){ $loged_in= true; } if($loged_in==true){ echo "You are loged in<br>"; }else{ //if login incorrect, plus attempt time $_SESSION['attempt']++; header("Location: $_SERVER[PHP_SELF]"); }}if(!empty($_SESSION['attempt'])){ echo "Number of attempt : ".$_SESSION['attempt'];}?><div id="SignIn"> <form method="post" action="<?=$_SERVER['PHP_SELF']; ?>?insert=ok"> <table width="350" border="0" bgcolor="#000077"> <tr> <td colspan="2" style="font:bold"> <font color="#DDDDDD" style="font:large">web</font> </td> </tr> </table> <table width="350" border="0" class="alphabox"> <tr> <td width="161" height="35">User Name: </td> <td width="253" height="35"> <input type="text" name="username" /> </td> </tr> <tr> <td height="36" width="161">Password: </td> <td width="253" height="36"> <input type="password" name="password" /> </td> </tr> <tr> <td colspan="2"> <input type="Submit" name="Submit" value=" Login " width="60"> </td> </tr> </table> <table width="350" border="0"> <tr> <td colspan="3"> <a href="pwd4got.php"><font size="2"> Forgot Password? Click here for assistance </font> </a> </td> </tr> </table> </form></div>[/code]Remember,The session will be destroy when user close browser then user can re attempt again Quote Link to comment https://forums.phpfreaks.com/topic/28218-login-security-php/#findComment-129455 Share on other sites More sharing options...
atck Posted November 24, 2006 Author Share Posted November 24, 2006 i cannot do it..give detile example plz.. Quote Link to comment https://forums.phpfreaks.com/topic/28218-login-security-php/#findComment-129511 Share on other sites More sharing options...
atck Posted November 24, 2006 Author Share Posted November 24, 2006 can give me coding about this problum...i want login security 4 user difrent..plz.. Quote Link to comment https://forums.phpfreaks.com/topic/28218-login-security-php/#findComment-129515 Share on other sites More sharing options...
alpine Posted November 24, 2006 Share Posted November 24, 2006 Please visit the freelance section if you want someone to write you a fully working script.http://www.phpfreaks.com/forums/index.php/board,8.0.html Quote Link to comment https://forums.phpfreaks.com/topic/28218-login-security-php/#findComment-129622 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.