note 55939 deleted from function.ereg by nlopess
| From: | nlopess@php.net | Date: | Sun, 02 Oct 2005 18:06:44 +0000 |
| Subject: | note 55939 deleted from function.ereg by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-96212@lists.php.net to get a copy of this message | ||
Note Submitter: webmaster at sismpa dot it
----
On PHP 5 I use these functions to validate people names (on site registration), files and dir names
(on uploads) and safe html text to be stored in mysql.
-- People names
function convalida_nome($string){
if (ereg("[^[:space:]a-zA-Z0-9_.-\\']", $string))
{
return false;
}
else
{
return true;
}
}
-- Files and dirs
function convalida_file($string){
if (ereg("[^a-zA-Z0-9_-]", $string))
{
return false;
}
else
{
return true;
}
}
-- HTML text (to be put on MySQL after doing htmlentities() )
function convalida_titolo($string){
if (ereg("[^[:space:]a-zA-Z0-9_.-\\'\\"?!]", $string))
{
return false;
}
else
{
return true;
}
}