cashflowtips Posted September 10, 2007 Share Posted September 10, 2007 im looking for solution on how to check the password combination... here is the example: - $text = "onlyalphanumericcharacters012345"; if (ereg('[^A-Za-z0-9]', $text)) { echo "This contains characters other than letters and numbers"; } else { echo "This contains only letters and numbers"; } but the problem here is - i want the code only accept with these kind of combination: - a) alphabet + number b) alphabet + symbol c) number + symbol can anyone help me? thanks alot Quote Link to comment Share on other sites More sharing options...
btherl Posted September 10, 2007 Share Posted September 10, 2007 How do you define "symbol" ? Everything visible on the keyboard that is not alpha or numeric? Quote Link to comment Share on other sites More sharing options...
phat_hip_prog Posted September 10, 2007 Share Posted September 10, 2007 You might like to have a look at this... http://www.linuxquestions.org/questions/showthread.php?t=521792 which links to... http://www.owasp.org/index.php/OWASP_PHP_Filters Quote Link to comment Share on other sites More sharing options...
cashflowtips Posted September 10, 2007 Author Share Posted September 10, 2007 How do you define "symbol" ? Everything visible on the keyboard that is not alpha or numeric? yes, anything! Quote Link to comment Share on other sites More sharing options...
cashflowtips Posted September 11, 2007 Author Share Posted September 11, 2007 maybe my question is not very clear and i want to apologize for that... let me explain once again... what i really want is the code that can check where the input must have a) must have Alphabet + must have Number (if the input only one of these two, it will return false) b) must have Alphabet + must have Symbol (the condition same as A(above)) c) must have Number + must have Symbol (the condition same as A(above)) as for the Symbol, im not sure what is the basic one that usually been used by other website but i know some of them accept symbol as password characters to increase security (hard for hacker to guess the password) Quote Link to comment Share on other sites More sharing options...
btherl Posted September 11, 2007 Share Posted September 11, 2007 Are you checking for "at least one alpha" and "at least one number" ? So these would be valid: Nt4% NN99 55%%aa qwer!@#$ But these would be invalid abcd 1234 !@#$ because they only contain one class of characters Quote Link to comment Share on other sites More sharing options...
cashflowtips Posted September 11, 2007 Author Share Posted September 11, 2007 Are you checking for "at least one alpha" and "at least one number" ? So these would be valid: Nt4% NN99 55%%aa qwer!@#$ But these would be invalid abcd 1234 !@#$ because they only contain one class of characters exactly... thanks for more clear view on the question... can u help me with this Quote Link to comment Share on other sites More sharing options...
btherl Posted September 11, 2007 Share Posted September 11, 2007 Ok, some of that is easy: $got_alpha = preg_match('|[A-Za-z]|', $password); $got_num = preg_match('|[0-9]|', $password); But as for the symbols.. there are four groups of symbols in the ascii table $got_symbol = preg_match('|[ -/:-@[-`{-~]|', $password); That oughta work. After that you just need to check if (($got_alpha && $got_num) || ($got_alpha && $got_symbol) || $got_num && $got_symbol)) Quote Link to comment Share on other sites More sharing options...
cashflowtips Posted September 11, 2007 Author Share Posted September 11, 2007 thanks you so much 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.