note 53931 deleted from function.preg-match-all by jome

From: Date: Fri, 30 Sep 2005 19:12:54 +0000
Subject: note 53931 deleted from function.preg-match-all by jome
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-96084@lists.php.net to get a copy of this message
Note Submitter: beginner at home dot trying ---- I was trying to validate users name, password and any other for any funny characters, and took me a bit, but hope this helps u all out, there are many samples where that helped me out, and I am having a hard time trying to understand the pattern syntax and modifies, so I like simple! <?php function isGoodChar($test) { return !preg_match ("/[A-z0-9_]/",$test); } ?> this will test for anything that is not A-Z,a-z,0-9 or _ and return false if it does find something else <?php if (isGoodChar($user_name) == false) { error_(); // <-- what ever error routine u want } ?>

« previous php.notes (#96084) next »