title: Values from dynamically produced checkboxes
body: <p>I am trying to get the values of a dynamically created set of checkboxes in PHP but apparently I couldn't get it. The source codes are below.</p>
  
  <p>The "managestaff.php" page would allow searching for staff via their names and throws out a list of names with checkboxes for the admin to check them and click on a "delete" button at the bottom to delete the staff whom are being checked.</p>
  
  <p>The deletion would be done on "deletestaff.php" as the "delete" button on "managestaff.php" simply forwards these values to "deletestaff.php" to do deletion work of the staff.</p>
  
  <p>"managestaff.php" page codes:</p>
  
  <pre><code>&lt;b&gt;&lt;h3&gt;Manage Staff&lt;/h3&gt;&lt;/b&gt;&lt;br/&gt;
  
  &lt;form action="managestaff.php" method="POST"&gt;
  &lt;input name="form" type="hidden" id="form" value="true"&gt;
  &lt;table width=300&gt;
      &lt;tr&gt;
          &lt;td width=112&gt;Staff Name: &lt;/td&gt;
          &lt;td width=188&gt;&lt;input type="text" class="textfield" name="sname" /&gt;&lt;br/&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;&lt;br/&gt;
  &lt;input type="submit" value="submit" /&gt;
  &lt;/form&gt;
  &lt;?php
  if (isset($_POST['form']) &amp;&amp; (isset($_POST['sname'])) &amp;&amp; $_POST['form'] == 'true') {
  
  $space = '&amp;nbsp;&amp;nbsp;&amp;nbsp;';
  $staffname = mysql_real_escape_string($_POST['sname']);
  $query = 'SELECT * from staff where staffname like \'%' . $staffname . '%\'';
  
  $result = mysql_query($query) or die(mysql_error());
  
  if (mysql_num_rows($result) != 0) {
      echo '&lt;br&gt;&lt;br&gt;';
      echo '&lt;table&gt;';
      echo '&lt;tr&gt;&lt;th&gt;Staff ID' . $space . '&lt;/th&gt;&lt;th&gt;Staff Name' . $space . '&lt;/th&gt;&lt;/tr&gt;';
      echo '&lt;form action="deletestaff.php" method="POST"&gt;';
      echo '&lt;input name="delstaffform" type="hidden"&gt;';
      while ($row = mysql_fetch_array($result)) {
          echo '&lt;tr&gt;';
          echo '&lt;td&gt;' . $row['staffid'] . '&lt;/td&gt;&lt;td&gt;' . $row['staffname'] . '&lt;/td&gt;';
  
          // :Begin - dynamic checkbox generation for deleting staff
          echo '&lt;td&gt;';
          echo '&lt;input type="checkbox" name="delstaff" value="' . $row['staffid'] . '"                 /&gt;';
          echo '&lt;/td&gt;';
          // :End
          echo '&lt;/tr&gt;';
      }
      echo '&lt;tr align="right"&gt;&lt;td colspan="3"&gt;&lt;input type="submit" value="delete"/&gt;&lt;/td&gt;&lt;/tr&gt;';
      echo '&lt;/form&gt;';
      echo '&lt;/table&gt;';
  
  }
  }
  ?&gt;
  </code></pre>
  
  <p>"deletestaff.php" page codes:</p>
  
  <pre><code>&lt;?php
  print_r('POST: ' . $_POST);
  
  echo '&lt;br&gt;';
  
  if (isset($_POST['delstaffform']) &amp;&amp; isset($HTTP_POST_VARS)) {
      echo 'Submission of delstaffform FOUND !';
      echo 'Staff to delete' . $HTTP_POST_VARS['delstaff'];
  }
  else{
      echo 'Submission of delstaffform NOT FOUND !';
  }
  ?&gt;
  </code></pre>
  
  <p>The "deletestaff.php" doesn't do delete for now as it's a test page. </p>
  
  <p>The current output I get is "Submission of delstaffform NOT FOUND !".</p>
  
  <p>Thanks for the solutions.</p>