You are here: Re: error checking a null array « PHP « IT news, forums, messages
Re: error checking a null array

Posted by David Robley on 08/01/05 08:18

Jack Jackson wrote:

> hi,
> I have checkboxes beging dynamically generated. to seperate tasks in
> error checking I have added he arrays not just to $_POST but to
> $_POST[cb] so names (derived from question numbers) are for example:
>
> $_POST[cb][7]
>
> A dump of $_POST would therefore include something like
>
> ["cb"]=> array(1) { [7]=> array(1) { [0]=> string(3) "124" } }
>
> So I did this:
>
> //error checking for checkboxes
> foreach ($cb as $cbkey => $cbvalue)
> {
> foreach($cbvalue as $cbkey2=>$cb_answers)
> {
> if( !array_key_exists($_POST[$cbkey], $cb));
> {
> $message[$cbkey]=1;
> }
> }
> }
>
> This almost works. The problem is that if someone doesn't check a
> checkbox, NOTHING related to the checkbox gets sent to $_POST; if I
> insert a hidden value of something, then that hidden value gets passed
> whether the user inputs something or not, since I need an entirely
> server-side solution. Is there a way to send something to tell the error
> checker whether for example $_POST[cb][7] is empty or null, so I can set
> the error message to one if it's empty?

I think you might find empty() and isset() fairly useful here.



Cheers
--
David Robley

Don't play stupid with me! I'm better at it.

 

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

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