Re: Checking for empty()

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

 



If you just want to disallow strings of only whitespace,
http://php.net/trim them first.

The ideal sanitization, however, lists all the characters you DO want
to allow, rather than attempting (and probably failing) to try to
consider all the ways a user might (intentionally or not) screw up.

$CLEAN['name'] = preg_replace('/[^a-z0-9\'",\\. -]/i', '?',
$_REQUEST['name'];

might be an example that would cover virtually all names.

At least for Latin1 character set languages...

You're on your own if you need Unicode and all that...

Though the above would be not much worse than attempting to render
UTF-16 as Latin1 anyway, so there ya go.

NOTE:
An Apple developer from the 80s was named 'Bo3b'
And that 3 is not a typo.
Hippie parents.
That is why I intentionally allow 0-9.
Anybody who poked around on a Fat Mac [*] will remember the hidden
files with 'bo3b' as part of their name or resource type.  Yup.  That
was him.
YMMV
NAIAA
IANAL

* Fat Mac: 128K RAM!  And you could copy Mac Floppies with only a
couple floppy swaps!  Whoo Hooo!!!  Those were the days.  Lode Runner
totally rocked, though. :-)

On Wed, June 14, 2006 1:09 pm, Ashley M. Kirchner wrote:
>
>     I have a form with various fields on it that I want to make sure
> aren't empty or the user didn't just hit the space bar or return (in a
> text field).  What's the best way to do this?  Seems empty() will fail
> on a textarea if the user simply hits a space or return and submits
> the
> form.
>
> --
> W | It's not a bug - it's an undocumented feature.
>   +--------------------------------------------------------------------
>   Ashley M. Kirchner <mailto:ashley@xxxxxxxxxx>   .   303.442.6410
> x130
>   IT Director / SysAdmin / Websmith             .     800.441.3873
> x130
>   Photo Craft Laboratories, Inc.            .     3550 Arapahoe Ave.
> #6
>   http://www.pcraft.com ..... .  .    .       Boulder, CO 80303,
> U.S.A.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Like Music?
http://l-i-e.com/artists.htm

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