monkeybidz Posted December 13, 2007 Share Posted December 13, 2007 I have a user claiming to not be able enter mmmmmm as password. My script is set to check for length of 6 or more or empty. Could this be something PHP5 cannot recognize? I recreated the issue, but seems works fine on my end. Quote Link to comment Share on other sites More sharing options...
monkeybidz Posted December 13, 2007 Author Share Posted December 13, 2007 The user also gets an error when numeric is used before alpha like 123mmmm <?php if(!$password){ return "004"; } if(strlen($password) < 6){ return "011"; } ?> Quote Link to comment Share on other sites More sharing options...
Xyphon Posted December 13, 2007 Share Posted December 13, 2007 The user also gets an error when numeric is used before alpha like 123mmmm <?php if(!$password){ return "004"; } if(strlen($password) < 6){ return "011"; } ?> why dont you turn the strlen password into something like this if(strlen($password) < 6 echo "Sorry, you must have 6 or more characters"; else form data here Quote Link to comment Share on other sites More sharing options...
monkeybidz Posted December 13, 2007 Author Share Posted December 13, 2007 thats not the problem, they are getting the errors OK, but not registereing 123mmmm as 7 characters or it sees mmmmmm as empty or missing. Quote Link to comment Share on other sites More sharing options...
Xyphon Posted December 13, 2007 Share Posted December 13, 2007 Ah.. Did you put the exit; afterwards? Because mine says if (strlen($_POST['pass']) < 4) { echo "<font color='red'>Sorry, your password must be over 4 characters. Please go <a href='register.php'>back.</a></font>"; exit; and it works perfectly. Quote Link to comment Share on other sites More sharing options...
monkeybidz Posted December 13, 2007 Author Share Posted December 13, 2007 That did not work either, I keep getting the error as string length too short. I think it has to do with alpha-numeric. It does not seem to accept numbers before alphabets. Quote Link to comment Share on other sites More sharing options...
Crew-Portal Posted December 13, 2007 Share Posted December 13, 2007 Try This: FUNCTION: <?php function valid_password($pass1) { //validate password if(ereg("^[a-zA-Z0-9]+$",$pass1) && strlen($pass1) >= 5 && strlen($pass1) <= 20) return true; else return false; } ?> FOR SCRIPT: <?php if(!valid_password($_POST['pass1'])) { $error = $tblstart . 'You Did Not Enter A Password Or Your Password Is Invalid' . $tblend; } ?> This should work, A little more complicated than your code but for verfication the more the merrier! Quote Link to comment Share on other sites More sharing options...
monkeybidz Posted December 13, 2007 Author Share Posted December 13, 2007 ereg conflicts with another datacheck on page. How would I put: If $password starts with numbers, then return "Password must begin with an Alphabet." Quote Link to comment Share on other sites More sharing options...
corylulu Posted December 13, 2007 Share Posted December 13, 2007 Do you have the full function for the code available so we can see any other underlining problems? If you wanna just avoid the issue and put a little disclaimer, yours should do, but in sakes of learning the problem and avoiding it from happening again, i think we should look for a conclusion. Quote Link to comment Share on other sites More sharing options...
Crew-Portal Posted December 13, 2007 Share Posted December 13, 2007 Im really not sure how to do this and I am always trying new things so here is how I think it would be done... <?php if(!$password[0](ereg("^[a-zA-Z]+$",$password))) { $error = 'Your Password Has To Start Off Alpha! (A-Z)'; } ?> Quote Link to comment Share on other sites More sharing options...
monkeybidz Posted December 14, 2007 Author Share Posted December 14, 2007 The problem was in Mysql. Table Type. Thanks! Quote Link to comment 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.