You are here: Re: testing the condition of a pair of fields « All PHP « IT news, forums, messages
Re: testing the condition of a pair of fields

Posted by Janwillem Borleffs on 06/26/06 22:47

Ian Davies wrote:
> if ((isset($_POST['Link']) && $_POST['Link'] !=='') &&
> (isset($_POST['uploadedfile']) && $_POST['uploadedfile'] !=='')) {
> $error_msg.="<br>You can't select to upload a link and a file at the
> same time.";
>

This way, the condition only applies when both sub-conditions are true (both
fields are non-empty); replace the && between the sub-conditions with ||

if ((isset($v) && $v !=='') || (isset($v2) && $v2 !=='')) {
...
}

> curiously the following works
>
> if(empty($_POST['Link']) || $_POST['Link'] ='' &&
> empty($_FILES['uploadedfile']) || $_FILES['uploadedfile'] ='') {
> $error_msg.="<br>You didn't select whether to upload a link or a
> file."; }
>

That's because with the ||, only one test has to pass. Also note that you
are not compatring values (==) but assigning them (=).


JW

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация