multiple checkbox problem... double count??

From: Date: Sat, 15 Feb 2003 10:31:25 +0000
Subject: multiple checkbox problem... double count??
Groups: php.general 
Request: Send a blank email to php-general+get-135648@lists.php.net to get a copy of this message
Hello, I'm having a problem with multiple checkboxs with same name. Here are my code snippets. --checkbox.html-- <html><head></head><body> <form action="checkbox.php" method="post"> <input type="checkbox" name="fruits[]" value="apple" checked>apple <input type="checkbox" name="fruits[]" value="orange" checked>orange <input type="checkbox" name="fruits[]" value="grapes">grapes <input type="image" name="submit" value="submit"> </form> </form> </body></html> --checkbox.php-- <?php $fruits=$_POST['fruits']; echo "count=".count($fruits)." "; foreach($fruits as $fruit) { echo '-'.$fruit.'-'; } ?> --output-- count=3 -apple--orange--orange- I'm gettin duplicate entries in the array (two oranges). It may have to do with "image" type I'm using to submit the form. Can anyone help? Thanks, Scott

« previous php.general (#135648) next »