title: Unable to retrieve values from checkbox array
body: <p>I have multiple checkboxes(array) as codes below:</p>
  
  <pre><code>&lt;div class="checkbox"&gt;
      &lt;label&gt;&lt;input type="checkbox" name="major[]" value="Business" /&gt; Business&lt;/label&gt;
  &lt;/div&gt;
  &lt;div class="checkbox"&gt;
      &lt;label&gt;&lt;input type="checkbox" name="major[]" value="Public Affairs / Law" /&gt;Public Affairs / Law&lt;/label&gt;
  &lt;/div&gt;
  &lt;div class="checkbox"&gt;
      &lt;label&gt;&lt;input type="checkbox" name="major[]" value="Medicine" /&gt;Medicine&lt;/label&gt;
  &lt;/div&gt;
  &lt;div class="checkbox"&gt;
      &lt;label&gt;&lt;input type="checkbox" name="major[]" value="Literature / Writing / Journalism" /&gt;Literature / Writing / Journalism&lt;/label&gt;
  &lt;/div&gt;
  &lt;div class="checkbox"&gt;
      &lt;label&gt;&lt;input type="checkbox" name="major[]" value="Technology" /&gt;Technology&lt;/label&gt;
  &lt;/div&gt;
  &lt;div class="checkbox"&gt;
      &lt;label&gt;&lt;input type="checkbox" name="major[]" value="Engineering" /&gt;Engineering&lt;/label&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>When the form submitted, I tried to retrieve the selected values by:</p>
  
  <pre><code>         print_r($_POST['major']);
  </code></pre>
  
  <p>it prints:</p>
  
  <pre><code>         Array ( [0] =&gt; [1] =&gt; )
  </code></pre>
  
  <p>It detecting two checkboxes are ticked but it somehow unable to retrieve the values out. What am I doing wrong?</p>
  
  <p>=======================PHP snippets============================</p>
  
  <pre><code>require 'dbconnect.php';
  
  
  if($_SERVER["REQUEST_METHOD"] == "POST"){
                   if(isset($_POST['major'])){
  
                  $top_majors = implode(',', $_POST['top_three_major']);
  
                  echo $top_majors;
              }else{
  
                  $top_majors = '-';
  
              }
  }
  </code></pre>
  
  <p>=======================Solved============================</p>
  
  <p>OK, I solved my problem. It was a stupid mistake that I try to clear the form fields when the browser was ready, thus, the checkbox values are reset before it able to POST.</p>
  
  <p>Thank you guys for helping me! Especially Learner Student, I appreciate that! I hope I can vote you all up but too bad my reputation was far too low.</p>
  
  <p>Thanks again.</p>