Re: form question
| From: | Martin A. Marques | Date: | Wed, 19 Jul 2000 14:05:19 +0000 |
| Subject: | Re: form question | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-7274@lists.php.net to get a copy of this message | ||
OK, lets see what I did. I put values to all the checkboxes (unique values).
I put quotes at all the values. I submit the form and all I get is an empty
array. Why is it? I've done everything you people told me, and I find no
reason for this to happen. The page looks like this:
<html>
<body>
<form action="prueba-resultado.php" method="post">
<?
echo(printf("<input type=\"checkbox\" checked name=\"ar_pru[]\"
value=\"1\"><BR> \n"));
echo(printf("<input type=\"checkbox\" checked name=\"ar_pru[]\"
value=\"2\"><BR> \n"));
echo(printf("<input type=\"checkbox\" checked name=\"ar_pru[]\"
value=\"3\"><BR> \n"));
echo(printf("<input type=\"submit\" value=\"Go!\"> \n"));
?>
</form>
</body>
</html>
and the script prueba-resultado.php looks like this:
<html>
<body>
<?
if (isset($ar_pru)){
echo "The variable is set.<br>\n";
}else{
echo "The variable is not set. <br> \n";
die;
}
if (! key($ar_pru)){
echo "The array is empty.<br>\n";
}
for ($i=1;key($ar_pru);$i++){
echo(sprintf("La variable es %s, y su valor %s \n <br> \n",$i,
$ar_pru[$i]));
next($ar_pru);
}
?>
</body>
</html>
and the output on the navigator is this:
<html>
<body>
The variable is set.<br>
The array is empty.<br>
</body>
</html>
Any ideas on this?
On Wed, 19 Jul 2000, Jurian wrote:
> There is nothing in it, cause you didn't put any values in it. You *MUST*
> define a value for every checkbox, then on the next page, the array will
> have those values in it. Of course you get an array with empty values, how
> can php know what to put in a field if you don't give it a value? Right, it
> can't.
>
> Give every checkbox a unique value, then try again, and you'll see that it
> works.
--
"And I'm happy, because you make me feel good, about me." - Melvin Udall
-----------------------------------------------------------------
Martín Marqués email: martin@math.unl.edu.ar
Santa Fe - Argentina http://math.unl.edu.ar/~martin/
Administrador de sistemas en math.unl.edu.ar
-----------------------------------------------------------------