php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5550 <input type=checkbox name=\"test[$i]\"> is not working correctly when submittin
Submitted: 2000-07-13 06:31 UTC Modified: 2000-07-26 21:50 UTC
From: stormlord at the dot net dot nz Assigned:
Status: Closed Package: Other
PHP Version: 4.0 Release Candidate 2 OS: Linux
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: stormlord at the dot net dot nz
New email:
PHP Version: OS:

 

 [2000-07-13 06:31 UTC] stormlord at the dot net dot nz
<?
if(!$submit)
{
  echo"<form method='POST'>\n";
  for($i=0;$i<10;$i++)
  {
    echo"<input type=checkbox name=\"todel[$i]\" value=\"pjd$i\"><br>\n";
  }
  echo"<input type=submit name=submit value=submit><br>\n";
  echo"</form>\n";
}
else
{
  for($i=0;$i<count($todel);$i++)
    echo"$i - todel = ".$todel[$i]."<br>";
}
?>


Ok.. now try selecting 2,3,4 in the check box and submit and see if it gives you
the correct values.. its just not working correctly!!! :LLLLL Help!! :)

I've installed PHP4 the way the www.linuxguruz.org site have listed in their
tutorial for PHP + MYSQL + SSL :)

Cheers
Paul.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-26 21:50 UTC] zak@php.net
This is a logical error in the program, not a bug.

When you loop over your values with the line:
  for($i=0;$i<count($todel);$i++)
you are only running the loop as many times as you have elements in your array. If 2,3,4 are selected, then the count of $todel is 3... so the 4th element will never be reached.

Try changing the contents of your else statement to:
foreach ($todel as $key => $value)
    echo "$key - todel = ".$todel[$key].'<br>';
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 12:01:33 2025 UTC