Re: Checking for empty()

From: Date: Wed, 14 Jun 2006 18:26:42 +0000
Subject: Re: Checking for empty()
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-238000@lists.php.net to get a copy of this message
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. I often use trim() on *any* incoming data as the first step to sanitizing the data - that gets rid of the whitespace problem you describe. a second step often involves using strval(), intval(), floatval() et al. subsequent steps might involve funcs like striptags() to remove any HTML that some b****** might be trying to XSS your site with. <sidenote> in the future the filter extension will provide robust, standardized ways to santize incoming data - I think it ill be a huge step forward. </sidenote> >

« previous php.general (#238000) next »