RE: [PHP] validating user input

From: Date: Wed, 24 Apr 2002 13:09:17 +0000
Subject: RE: [PHP] validating user input
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-94370@lists.php.net to get a copy of this message
Hi Drouet, I've been asking about this too and here's what I've been working on. It checks for letters, numbers, puncuation, and max and min length. I was told any of the puncation was safe as long as you addslashes before you put it into the database. function check_input($user_input, $min=0, $max=0, $text=false, $number=false, $special=false) { $pattern = ""; if ($text) $pattern .= "a-zA-Z"; if ($number) $pattern .= "0-9"; if ($special) $pattern .= 'À-ÖØ-öø-ÿ[:space:]\~\!\[\]\`\@\#\$\%\^\&\*\(\)\_\+\-\=\\\\{\}\|\:\"\;\'\<\> \?\,\.\/'; $regexp = '/^['.$pattern.']*$/i'; if( preg_match($regexp, $user_input) && strlen($user_input) <= $max && strlen($user_input) >= $min ) echo "it passes"; else echo "didn't pass"; } -----Original Message----- From: DrouetL@ldnegoce.com [mailto:DrouetL@ldnegoce.com] Sent: April 24, 2002 3:49 AM To: php-general@lists.php.net Subject: [PHP] validating user input Hi the M.L. I have to validate forms user inputs before the construction of my query to my Oracle DB Does anybody know the list of characters that should be rejected (for example ;) ? Do you have a function to validate it ? regards Laurent Drouet -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#94370) next »