chris_s_22 Posted January 17, 2009 Share Posted January 17, 2009 ok the plan for this scriopt is that when someone types in the password feild it tells you how strong it is, it it contains a lower case it is given a + 1 rating, if there is a upprcase enter again given a + 1 rating, again with a number a + 1 rating is given. now the part where im going wrong if one of these characters is entered i want it to have a + 1 rating !"£$%^&*()-_=+#~'@;:/?.>,<\|`¬ as u can see what ive got it currently but is this right or what should it be to achieve my goal. or is my code fie and have gone wrong somewhere else? then in the end the total score is added up and the echo for the accumlative points is displayed <?php $do = $_GET['do']; switch($do) { case 'check_password_strength': $password = $_GET['pass']; $strength = 0; // letters (lowercase) if(preg_match("/([a-z]+)/", $password)) { $strength++; } // letters (uppercase) if(preg_match("/([A-Z]+)/", $password)) { $strength++; } // numbers if(preg_match("/([0-9]+)/", $password)) { $strength++; } // non word characters if(preg_match("/(W+)/", $password)) { $strength++; } header('Content-Type: text/xml'); header('Pragma: no-cache'); echo '<?xml version="1.0" encoding="UTF-8"?>'; echo '<result><![CDATA['; switch($strength) { case 1: echo '<div style="width: 25%" id="password_bar">Very Weak</div>'; break; case 2: echo '<div style="width: 50%" id="password_bar">Weak</div>'; break; case 3: echo '<div style="width: 75%" id="password_bar">Strong</div>'; break; case 4: echo '<div style="width: 100%" id="password_bar">Very Strong</div>'; break; } echo ']]></result>'; break; default: echo 'Error, invalid action'; break; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/141219-password-strength-script/ Share on other sites More sharing options...
chris_s_22 Posted January 17, 2009 Author Share Posted January 17, 2009 please someone help it driving me insane the bit what isnt working is the non characters if non characters are entered into the password feild it doesnt add to the stregth uppper cases,lower cases and numbers all do Quote Link to comment https://forums.phpfreaks.com/topic/141219-password-strength-script/#findComment-739263 Share on other sites More sharing options...
Mark Baker Posted January 17, 2009 Share Posted January 17, 2009 "/(W+)/" W is matching for the letter W I suspect you mean "/(\w+)/" Quote Link to comment https://forums.phpfreaks.com/topic/141219-password-strength-script/#findComment-739265 Share on other sites More sharing options...
DeanWhitehouse Posted January 17, 2009 Share Posted January 17, 2009 Please wait at least 12 hours before bumping threads, no thread is more important than the next Quote Link to comment https://forums.phpfreaks.com/topic/141219-password-strength-script/#findComment-739266 Share on other sites More sharing options...
chris_s_22 Posted January 17, 2009 Author Share Posted January 17, 2009 i already tried if(preg_match("/(w+)/", $password)) { Quote Link to comment https://forums.phpfreaks.com/topic/141219-password-strength-script/#findComment-739304 Share on other sites More sharing options...
Mark Baker Posted January 17, 2009 Share Posted January 17, 2009 i already tried if(preg_match("/(w+)/", $password)) { Reread what I wrote carefully, looking for \ You're trying to match word characters, not the letter w And you should be testing for the negative. You're after characters that aren't word characters Quote Link to comment https://forums.phpfreaks.com/topic/141219-password-strength-script/#findComment-739318 Share on other sites More sharing options...
chris_s_22 Posted January 17, 2009 Author Share Posted January 17, 2009 {quote]Reread what I wrote carefully, looking for \ You're trying to match word characters, not the letter w And you should be testing for the negative. You're after characters that aren't word characters sorry i missed that tanks it working the way i want it to now thx Quote Link to comment https://forums.phpfreaks.com/topic/141219-password-strength-script/#findComment-739349 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.