Re: Form Validation filter - Regex Q

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

 



On Tue, 10 Nov 2009 09:34:52 -0800, Haig Davis wrote:

>         foreach($_POST as $keyTemp => $valueTemp){
>             $key = mysqlclean($keyTemp);
>             $value = mysqlclean($valueTemp);

Mysql and form validation are totally unrelated.
In my mind, this seems spectacularly misguided.

>             if($key = ("$customerServiceEmail") || ("$billingEmail")){
> 
> if(preg_match("/^([a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4})*$/",
> $value)){

Just as almost every other email validation regexp
I have seen, this has a few imperfections:

* It does not allow some valid email addresses (mail!box@xxxxxxxxxxx)
* It does not allow some valid domains (*.museum)
* It allows invalid email addresses (.@xxxxxxxxxxx)
* It allows invalid domains (example..com)

>                     $style = "yellow";
>                     $formMsg = "Invalid Characters";
>                     $bad = $key;

Personally, I'd put the invalid keys in an array and
mark all the problematic fields at once.


/Nisse

-- 
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