anna90
05-23-2009, 07:24 PM
Can you tell me how to write it properly ?
if(isset($_POST['button'])) && ($_POST['form'] = !null)){
echo 'choose something';
}
else{
echo 'great choice!';
}
timgolding
05-23-2009, 07:30 PM
if(isset($_POST['button'])) && ($_POST['form'] != null)){
echo 'choose something';
}
else{
echo 'great choice!';
}
or
if(!empty(@$_POST['form'])){
echo 'choose something';
}
else{
echo 'great choice!';
}
The @ turns off error reporting for getting the function/variable after so avoids the need to use isset.
anna90
05-23-2009, 07:36 PM
if(isset($_POST['button'])) && ($_POST['form'] != null)){
echo 'choose something';
}
else{
echo 'great choice!';
}
or
if(!empty(@$_POST['form'])){
echo 'choose something';
}
else{
echo 'great choice!';
}
The @ turns off error reporting for getting the function/variable after so avoids the need to use isset.
first one
Parse error: syntax error, unexpected T_BOOLEAN_AND
second one
Parse error: syntax error, unexpected '@', expecting T_STRING or T_VARIABLE or '$'
timgolding
05-23-2009, 07:46 PM
Sorry i didn't test them let me fix that.
timgolding
05-23-2009, 07:52 PM
Sorry empty seems to check if it exsists and is empty all in one hit.
<?php
if(empty($_POST['form'])){
echo 'choose something';
}
else{
echo 'great choice!';
}
?>
However you might want to use
<?php
if(!isset($_POST['button']) && $_POST['form'] == ""){
echo 'choose something';
}
else{
echo 'great choice!';
}
?>
As empty returns true if $_POST["form"] is set to 0 for instance
anna90
05-23-2009, 07:59 PM
thank you!
a hug to you :rolleyes:
timgolding
05-23-2009, 08:06 PM
thank you!
a hug to you :rolleyes:
:D thanks
venegal
05-24-2009, 02:40 AM
If by how to write it properly you meant why doesn't my code work it's because you forgot a left paren right after the if.