password alphanumeric php without use regex -
i try this.
for($i=0;$i<$length;i++) { if(!ctype_alpha($password[$i]) { header("location:regist.php?err=password not contain letter"); } else if(!is_numeric($password[$i])) { header("location:regist.php?err=password not contain numbers"); } else { //?? } }
how validate password if password must alphanumeric without using regular expression ?
i think looking ctype_alnum
check- http://www.php.net/manual/en/function.ctype-alnum.php
update-
you can check special characters in string like-
<?php $test = "password123"; $special_char = "#$%^&*()+=-[]';,./{}|:<>?~"; if (false === strpbrk($test, $special_char)) { echo "good password"; } ?>
Comments
Post a Comment