#18861 [NEW]: On a form, a "checkbox" array does not appear to be indexing properly.
| From: | tony at cigardiary dot com | Date: | Sun, 11 Aug 2002 23:28:37 +0000 |
| Subject: | #18861 [NEW]: On a form, a "checkbox" array does not appear to be indexing properly. | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-16516@lists.php.net to get a copy of this message | ||
From: tony@cigardiary.com
Operating system: Linux thebe 2.2.14
PHP version: 4.1.2
PHP Bug Type: Arrays related
Bug description: On a form, a "checkbox" array does not appear to be indexing properly.
The problem that I am having is that I have created an array of input
elements on a form, and I have been having problems with the checkbox
elements being passed appropriately.
When I fill in the form entries, I expect the corresponding values to be
populated, but when I select any of the checkboxes, for example, 1, 3, and
7... It always returns a Yes for 0,1, and 2.
This causes problems when I'm deleting the user's pictures based on their
selection. :)
Configure line follows.
---
'./configure' '--with-mysql'
'--with-apxs=/opt/apache-1.3.20/bin/apxs'
'--with-pear' '--with-openssl' '--with-imap'
'--with-imap-ssl'
'--with-curl' '--with-gd' '--with-png-dir=/usr/lib'
'--with-zlib-dir=/usr/lib' '--with-jpeg-dir=/usr/lib' '--with-ttf'
'--enable-track-vars' '--with-pspell' '--enable-ftp'
'--enable-memory-limit' '--enable-inline-optimization'
'--disable-debug'
'--enable-safe-mode' '--enable-magic-quotes' '--with-gettext'
'--with-xml'
---
A sample script follows.
---
<?php
if (isset($submit)) {
for ($i=0; $i<26; $i++) {
echo 'i='.$i.' Image line='.$img[$i].' Text
line='.$txt[$i].'
Delete line='.$dlt[$i].'<BR>';
}
} else { // if (isset($submit))
?>
<FORM ENCTYPE="multipart/form-data" ACTION="<?php echo $PHP_SELF
?>?id=<?php echo $id ?>" METHOD=POST>
<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="100000">
<TABLE CELLPADDING="3">
<?php
for ($j=0; $j<26; $j++) {
if ($j == 0) $imagedesc = 'Main Image'; else $imagedesc = 'Image #'.$j;
echo '<TR><TD COLSPAN="2">'.$imagedesc.' <INPUT
NAME="img[]"
TYPE="file"> <INPUT TYPE="checkbox" NAME="dlt[]"
VALUE="Yes"> Delete?
</TD></TR>';
echo '<TR><TD>'.$image[$j].'</TD><TD><TEXTAREA
NAME="txt[]" ROWS="6"
COLS="30">'.$text[$j].'</TEXTAREA></TD></TR>';
}
?>
</TABLE>
<INPUT NAME="submit" TYPE="submit" VALUE="Send File(s)">
</FORM>
<?php
} // end of if isset($submit)
?>
---
Hope you can help,
-Tony
--
Edit bug report at http://bugs.php.net/?id=18861&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=18861&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=18861&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=18861&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=18861&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=18861&r=support
Expected behavior: http://bugs.php.net/fix.php?id=18861&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=18861&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=18861&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=18861&r=globals