Re: question regarding form filtering

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,
       You can write some basic functions such as checking length of 
variable, removing special character, checking number or string, trimming 
blank lines and so on. And then you can use this functions together and you 
can write new functions. For example, if you want to check number (such as 
digit count is 4), you can write like a checknumber($number,$digit). With 
this function, you can use like length of variable function, removing 
special character function, checking number or string function and trimming 
blank lines function together. :)

-- 
Haydar TUNA
Republic Of Turkey - Ministry of National Education
Education Technology Department Ankara / TURKEY
Web: http://www.haydartuna.net

""Tim Earl"" <user@xxxxxxxxxxxxx> wrote in message 
news:36.25.34414.FE886F54@xxxxxxxxxxxxxxx
> HI all,
>
>
>
> Well I have been going through various methods on filtering form data, and
> the one I never see is filtering form data using regular expressions,
> (although the html form and validition class by Manuel Lemos does seem to
> use them) this is the only I could find.
>
>
>
> I often see lines like (for checking a 4 character number for example):
>
>
>
> $input_value = html_entities($input_value);
>
> If (strval(intval($input_value)) && strlen($input_value) == 4) {
>
>            // do something with validated data (maybe put in valid array 
> or
> something)
>
> }
>
>
>
> Ok so whats wrong with good ole:
>
>
>
> If (preg_match('/^[0-9]{4}$/',trim($input_value)) {
>
>            // do something with validated data (maybe put in valid array 
> or
> something)
>
> }
>
>
>
> Am I going to get a performance hit if I validate all my fields with 
> regular
> expressions?
>
> As I see it I am only calling one function (ok 2 with the trim()) to
> validate my form data.
>
> Just wondering what you all thought about these different methods, and 
> what
> approach suits best a given situation..
>
>
>
>
>
> Regards,
>
>
>
> Tim
>
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux