Click to See Complete Forum and Search --> : array keys


bunny1
03-21-2007, 08:06 PM
I have a bunch of checkboxes and then on the next pg i check which boxes were ticked

Here is my code

$i = 0;
$array = "";
foreach(array_keys($_POST) as $myKey)
{
echo "ee";
if (ereg('value', $myKey))
{
echo "hi";
$id = ereg_replace("value='checkbox'", "", $myKey);
$array[$i] = $id;
$i = $i+1;
}
}

If none of the boxes are ticked i get errors
I want to check if boxes were not ticked and if none was ticked then send a user to another page
But ive tried every way i can think of and cant get it to work

Any ideas?

NightShift58
03-22-2007, 06:17 AM
Check of existence with isset($_POST['mycheckbox']), or if you're using the array variant, use a loop and use something like isset($_POST['mycheckbox'][$x]).