note 29883 deleted from function.preg-match by sniper

From: Date: Tue, 30 Sep 2003 12:16:08 +0000
Subject: note 29883 deleted from function.preg-match by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-57403@lists.php.net to get a copy of this message
Note Submitter: Carlos Pires ---- Harvey Allen's Textarea validation: For starters, you can use ^ to prefix a list of allowed characters, and in the event there's a single one that does not fall into this list your condition will be triggered: if (preg_match("/[^A-z0-9_\-]/", $the_text)==1) { /*ERROR*/} else { /*okie dokie*/ } You may also find useful to start your "if" statement like this: if ($the_text!=addslashes($the_text) || preg_match("/[^A-z0-9_\-]/", $the_text)==1) ...that will mean the user entered slashes, backslashes and general weird stuff that otherwise will probably zark-off your script before it gets a chance to evaluate the regexp.

« previous php.notes (#57403) next »