Reply to error checking a null array

Your name:

Reply:


Posted by Jack Jackson on 08/01/05 07:36

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?

Dump of $_POST with no checkboxes checked
$_POST:
array(4) { ["action"]=> string(7) "process" ["cat"]=> string(1) "2"
["rs"]=> array(3) { [5]=> string(0) "" [6]=> string(0) "" [9]=>
string(0) "" } ["b"]=> string(8) "Continue" }

Dump of $_POST with checkboxes checked

array(5) { ["action"]=> string(7) "process" ["cat"]=> string(1) "2"
["cb"]=> array(2) { [7]=> array(5) { [0]=> string(1) "3" [1]=>
string(3) "124" [2]=> string(3) "125" [3]=> string(3) "127" [4]=>
string(3) "131" } [8]=> array(3) { [0]=> string(3) "141" [1]=>
string(3) "145" [2]=> string(1) "4" } } ["rs"]=> array(3) { [5]=>
string(0) "" [6]=> string(0) "" [9]=> string(0) "" } ["b"]=>
string(8) "Continue" }


Thanks so much In advance

[Back to original 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

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