You are here: Re: Check if any fields are filled in « PHP Programming Language « IT news, forums, messages
Re: Check if any fields are filled in

Posted by mtuller on 11/06/07 17:38

On Nov 6, 11:20 am, Justin Koivisto <justin.koivi...@gmail.com> wrote:
> mtuller wrote:
> > On Nov 6, 10:15 am, Darko <darko.maksimo...@gmail.com> wrote:
> >> On Nov 6, 4:50 pm, mtuller <mitul...@gmail.com> wrote:
>
> >>> I am creating a page for nomination and want to let the information
> >>> pass if any field are filled out, but if none are filled out, a
> >>> message will appear. I can't get the check to happen on multiple
> >>> fields though.
> >>> Here is what I have:
> >>> if ($nominee_first_name !=='' && $nominee_middle_initial !=='' &&
> >>> $nominee_last_name !=='')
> >>> What happens is that if all fields have content, the page passes, and
> >>> all I care about is that there is something entered in at least one
> >>> field.
> >> Replace && with ||
>
> > Sorry, the subject of this is wrong. I don't want to check if any
> > fields are empty. I want to check if all are empty. That's why I have
> > &&.
>
> if (empty($nominee_first_name) && empty($nominee_middle_initial) &&
> empty($nominee_last_name))
>
> --
> Posted via a free Usenet account fromhttp://www.teranews.com

I had tried that too. Except I used !empty.

if (!empty($nominee_first_name) && !empty($nominee_middle_initial) && !
empty($nominee_last_name))
{
// If not empty, insert into database
$nominee_field_query = "INSERT INTO faculty_nominations.nominations
(nominee_first_name, nominee_middle_initial, nominee_last_name,
nominee_comments)
values ('$nominee_first_name', '$nominee_middle_initial',
'$nominee_last_name', '$nominee_comments')";

// update database with infromation submitted
$db_query = mysqli_query ($db_connect, $nominee_field_query);

}
else
{
echo 'The fields are empty';
}

When I submit, if I have data in one field, but not in all, it
displays "The fields are empty". I want it to submit into the database
if any fileds are filled in, but not if there are no fields filled in.

 

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

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