Stickybomb Posted October 16, 2007 Share Posted October 16, 2007 I am working on a login system. this is the code i am using to validate and process the login. <?php if($_POST['submitted']=='yes'){ $user = $_POST['userid']; $pass = $_POST['pass']; $remember = $_POST['remember']; require_once('inc/sentry.php'); require_once('inc/validator.php'); $sentry = new Sentry; $validate = new Validator; //check if empty $validate->validateGeneral($user, "* You must enter a UserID<br /><br />"); $validate->validateGeneral($user, "* You must enter a Password<br /><br />"); //check length minimums $validate->validateMinLen($user, '3', "* UserID must be at least 3 characters<br /><br />"); //$validate->validateMinLen($pass, '6', "* Password must be at least 6 characters<br /><br />"); //check length maximums $validate->validateMaxLen($user, '30', "* UserID can not be more than 30 characters<br /><br />"); $validate->validateMaxLen($pass, '16', "* Password can not be more than 16 characters<br /><br />"); //check for password format //$validate->validateNumber($pass, "* Your Password must contain at least 1 letter and 1 number toataling 6-16 characters in length.<br /><br />"); //$validate->validateTextOnly($pass, "* Your Password muct contain at least 1 letter and 1 number toataling 6-16 characters in length.<br />"); if($validate->foundErrors()){ echo '<div id="errors"><p>'; $validate->listErrors($delim = '<br />'); echo '</p></div>'; include('templates/loginform.tpl'); exit(); }else{ echo 'Processing Login...'; //strip slashes and spaces $user = $validate->cleanValue($user); $pass = $validate->cleanValue($pass); //strip headers $user = $validate->stripHeaders($user); $pass = $validate->stripHeaders($pass); //validate login attempt $sentry->checkLogin($user,$pass,$remember); } }else{ include('templates/loginform.tpl'); } ?> basically if there are errors during validation it will display the errors above the login form, if there are no errors it should process the login. for some reason it is ignoring the else statement and displaying validation errors and still carrying out processing the login. anyone help me to figure this out thanks Quote Link to comment https://forums.phpfreaks.com/topic/73501-solved-login-system-problems/ Share on other sites More sharing options...
SirChick Posted October 16, 2007 Share Posted October 16, 2007 $user = $_POST['userid']; $pass = $_POST['pass']; $remember = $_POST['remember']; might want to put some injection protection on that... $user = mysql_real_escape_string($_POST['userid']); $pass = mysql_real_escape_string( $_POST['pass']); $remember = mysql_real_escape_string($_POST['remember']); Try changing that very last Else to an ElseIf(!($_POST['submitted']=='yes'){ include('templates/loginform.tpl'); } Quote Link to comment https://forums.phpfreaks.com/topic/73501-solved-login-system-problems/#findComment-370789 Share on other sites More sharing options...
Stickybomb Posted October 16, 2007 Author Share Posted October 16, 2007 its already there but thanks Quote Link to comment https://forums.phpfreaks.com/topic/73501-solved-login-system-problems/#findComment-370793 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.