php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18861 On a form, a "checkbox" array does not appear to be indexing properly.
Submitted: 2002-08-11 19:28 UTC Modified: 2002-08-11 23:25 UTC
From: tony at cigardiary dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.1.2 OS: Linux thebe 2.2.14
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: tony at cigardiary dot com
New email:
PHP Version: OS:

 

 [2002-08-11 19:28 UTC] tony at cigardiary dot com
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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-08-11 23:25 UTC] yohgaki@php.net
Sorry, but the bug system is not the appropriate forum for asking
support questions. Your problem does not imply a bug in PHP itself.
For a list of more appropriate places to ask for help using PHP,
please visit http://www.php.net/support.php

Thank you for your interest in PHP.

It does not work that way.
Get help from php-general.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 22:01:36 2025 UTC