Connecting Tech Pros Worldwide Forums | Help | Site Map

Control Structures

[Mystic]
Guest
 
Posts: n/a
#1: Jul 17 '05
I was just wondering. Im submitting a form, using this code:

if ((!empty($_POST['Name']) || !empty($_POST['E-Mail']) ||
!empty($_POST['Question'])) {

code...

}

What im testing for is

if name, email or question is set, do the following. But it is not working,
do I have the syntax right?

Also where is the document on the php site that explains || and &&

Thanks.



floele@gmail.com
Guest
 
Posts: n/a
#2: Jul 17 '05

re: Control Structures


>do I have the syntax right?

No, one "(" too much ;)

if (!empty($_POST['Name']) || !empty($_POST['E-Mail']) ||
!empty($_POST['Question'])) {

code...

}
[color=blue]
>Also where is the document on the php site that explains || and &&[/color]
http://www.php.net/manual/en/languag...rs.logical.php

Jacob Atzen
Guest
 
Posts: n/a
#3: Jul 17 '05

re: Control Structures


On 2005-01-19, [Mystic] <> wrote:[color=blue]
> I was just wondering. Im submitting a form, using this code:
>
> if ((!empty($_POST['Name']) || !empty($_POST['E-Mail']) ||
> !empty($_POST['Question'])) {
>
> code...
>
> }
>
> What im testing for is
>
> if name, email or question is set, do the following. But it is not working,
> do I have the syntax right?[/color]

It looks right. What is the expected result? What is the actual result?
Are you sure, your $_POST array contains, what you expect it to contain?
[color=blue]
> Also where is the document on the php site that explains || and &&[/color]

<http://www.php.net/manual/en/language.operators.logical.php>

--
Cheers,
- Jacob Atzen
Closed Thread