title: Codeigniter error: Undefined offset: 1 when processing checkbox from form
body: <p>I get this error type of error everytime I submit a form and process it.</p>
  
  <pre><code>A PHP Error was encountered
  
  Severity: Notice
  
  Message: Undefined offset: 1
  
  Filename: controllers/register_grp.php
  
  Line Number: 81
  </code></pre>
  
  <p>I have this form which contains dynamically created checkboxes, the number of which is determined by the user.</p>
  
  <pre><code>&lt;input class='main' type='checkbox' name='tshirttick[1]' id='tshirttick1' value='Yes' /&gt;
  &lt;input class='main' type='checkbox' name='tshirttick[2]' id='tshirttick2' value='Yes' /&gt;
  ...
  </code></pre>
  
  <p>Upon submit, I process it with this code:</p>
  
  <pre><code>$withtshirt = $this-&gt;security-&gt;xss_clean($this-&gt;input-&gt;post('tshirttick'));
  for ($i = 0; $i &lt; $num_of_members; $i++)
  {
       if ($withtshirt[$i] == "Yes")
       {
            $include_shirt = 'Y';
            $ticketcost += 150;
            $tshirtsize[$i] = $this-&gt;db-&gt;escape($tshirtsize[$i]);
       }
       else
       {
            $include_shirt = 'N';
            $tshirtsize[$i] = "-";
            $tshirtsize[$i] = $this-&gt;db-&gt;escape($tshirtsize[$i]);
       }
       $id = $this-&gt;register_model-&gt;addParticipant($i, $tshirtsize[$i], $include_shirt);
  }
  </code></pre>
  
  <p>The model <strong>addParticipant</strong> basically inserts a row into the database returns <strong>$this->db->insert_id();</strong></p>
  
  <p>The line number 81 pointed to by the error is this line:</p>
  
  <pre><code>if ($withtshirt[$i] == "Yes")
  </code></pre>
  
  <p>The rows are actually inserted successfully, but multiple instances of this error prints upon submitting, preventing the page from redirecting to another page. I guess the error prints everytime the loop iterates.</p>
  
  <p>How will I fix this? I just want the page to redirect after it executes all the insertion, but this 'notice' prevents it.</p>