title: How to fix 'php skipping my if statement'
body: <p>I got an html/php page which you can select only 2 or below from the checkbox values. I limited the selection using javascript. But my concern is if someone tried to use developer tools they can simply disable my script and select more values from the checkbox. So I thought that I need to count how many POST data am I getting from the checkbox.</p>
  
  <p>I tried using the count() in php to count the post and tried to echo the count and I get the right number. I then tried using an if statement that will echo if the selected is more than 2. It worked but when I use header('Location:') it skips it.</p>
  
  <pre><code>$countpres = count($_POST['pres']);
  if($countpres&gt;=3){
     header('Location:../index.php');
  }
  for($i=0;$i&lt;$countpres;$i++)
  {
  $sql1 = "UPDATE candidate_list SET vote_count= vote_count + 1 WHERE candidate_number = '". $_POST['pres'][$i]. "' ";
  mysqli_query($conn, $sql1);
  }   
  </code></pre>
  
  <p>I need to go to index.php if ever the user tries to send more than 2 of the options.</p>