--- Wade Smart <[EMAIL PROTECTED]> wrote:

> 06132006 1108 GMT-6
> 
> Im checking to see if all of these are empty I have to do something:
> 
> if (empty($_POST['phhome'] && $_POST['phcell'] && $_POST['phwork'] && 
> $_POST['email'])) {
> 
> But this isnt working and putting empty() around each didnt either. What 
> Im I not seeing?
> 
> wade

You definitely cannot put empty() around the whole series of expressions.  When 
you used the && as
"and" then you will get TRUE or FALSE which is never empty.

You may want to look at isset() for your $_POST values to determine if a value 
has been placed in
that variable.  If you don't you will likely generate notices and warnings when 
the variables have
not been set.

I would probably use:

if (! (isset($_POST['phhome']) and isset($_POST['phcell']) and 
       isset($_POST['phwork']) and isset($_POST['email'])))
{
 ...
}

If you need to check that the values are set and have a value then you might 
use a custom function
to check both isset() and !empty() or something similar.  One possibility is:

if (! ((isset($_POST['phhome']) and $_POST['phhome']) and 
       (isset($_POST['phcell']) and $_POST['phcell']) and  
       (isset($_POST['phwork']) and $_POST['phwork']) and 
       (isset($_POST['email'])  and $_POST['email'])
    ))
{
 ...
}

The above doesn't appeal to me because it is extra wordy (easy to make a 
mistake) and you don't
have a clear idea of which value is missing.  I would probably loop through the 
"required" fields
and keep track of ones which don't come up to standards.

James





------------------------ Yahoo! Groups Sponsor --------------------~--> 
Great things are happening at Yahoo! Groups.  See the new email design.
http://us.click.yahoo.com/TISQkA/hOaOAA/yQLSAA/HKFolB/TM
--------------------------------------------------------------------~-> 

Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to