Pavlos1316 Posted June 17, 2008 Share Posted June 17, 2008 Hi Is there a way to say if ALL fields are empty echo... ? Note that I need to check if ALL fields are empty! I have already tried if(empty($1) || empty($2)) and if(empty($1) && empty($2)) but it displays echo even if one of the fields is empty. Thank you Link to comment https://forums.phpfreaks.com/topic/110548-if-empty-statement/ Share on other sites More sharing options...
conker87 Posted June 17, 2008 Share Posted June 17, 2008 Are you using $1 and $2 as the variables? I'm sure you can't use numbers as variable names... Try: if (!$a && !$b) Link to comment https://forums.phpfreaks.com/topic/110548-if-empty-statement/#findComment-567127 Share on other sites More sharing options...
Pavlos1316 Posted June 17, 2008 Author Share Posted June 17, 2008 no $1 is just an example... Still doesn't works.. Link to comment https://forums.phpfreaks.com/topic/110548-if-empty-statement/#findComment-567136 Share on other sites More sharing options...
conker87 Posted June 17, 2008 Share Posted June 17, 2008 if (!$a || !$b || !$c ... || !$z) Now, that should work... (Woo, 400 posts ) Link to comment https://forums.phpfreaks.com/topic/110548-if-empty-statement/#findComment-567151 Share on other sites More sharing options...
zenag Posted June 17, 2008 Share Posted June 17, 2008 try this example <? if($_POST["submit"]=='submit') { $a=$_POST["ass"]; $b=$_POST["aaab"]; echo $a; echo $b; if(empty($a) && empty($b)) { echo "empty"; } } ?> <form action="" method="post"> <input type="text" name="ass" /> <input type="text" name="aaab" /> <input type="submit" name="submit" value="submit" /> </form> Link to comment https://forums.phpfreaks.com/topic/110548-if-empty-statement/#findComment-567154 Share on other sites More sharing options...
conker87 Posted June 17, 2008 Share Posted June 17, 2008 try this example <? if($_POST["submit"]=='submit') { $a=$_POST["ass"]; $b=$_POST["aaab"]; echo $a; echo $b; if(empty($a) && empty($b)) { echo "empty"; } } ?> <form action="" method="post"> <input type="text" name="ass" /> <input type="text" name="aaab" /> <input type="submit" name="submit" value="submit" /> </form> That's pretty much what I suggested. And don't use short tags -.- Link to comment https://forums.phpfreaks.com/topic/110548-if-empty-statement/#findComment-567158 Share on other sites More sharing options...
Pavlos1316 Posted June 17, 2008 Author Share Posted June 17, 2008 Nope.. Nothing works!!! Link to comment https://forums.phpfreaks.com/topic/110548-if-empty-statement/#findComment-567179 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.