Why does this return false?
Posted: Wed Feb 05, 2003 6:04 pm
I have a dynamic form, which generates fields like so:
It also passes a hidden field with the number of items it's sending. On the script it calls, I check that all these fields are filled out with this function:
In testing with 1 item, it has always returned false, even though all three fields are filled out. I tried just echoing each of the three values, which worked fine, and register_globals is on. I'm completely stumped and may have to give up my "geek" stauts at work... any ideas?
Code: Select all
<?php
for ($z = 1; $z <= $_POST['items']; $z++)
{
echo "<P ALIGN="left">";
echo "<B>Barcode for item #" . $z . ":</B> ";
echo "<INPUT TYPE="text" NAME="b1_" . $z . "">-";
echo "<INPUT TYPE="text" NAME="b2_" . $z . "">-";
echo "<INPUT TYPE="text" NAME="b3_" . $z . ""></P>";
}
?>Code: Select all
<?php
function checkbar($items)
{
for ($z = 1; $z <= $items; $z++)
{
if (${"b1_" . $z})
{
if (${"b2_" . $z})
{
if (${"b3_" . $z}) {$pass = true;}
else {$pass = false; break;}
}
else {$pass = false; break;}
}
else {$pass = false; break;}
}
return $pass;
}
?>