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.
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.
$countpres = count($_POST['pres']);
if($countpres>=3){
header('Location:../index.php');
}
for($i=0;$i<$countpres;$i++)
{
$sql1 = "UPDATE candidate_list SET vote_count= vote_count + 1 WHERE candidate_number = '". $_POST['pres'][$i]. "' ";
mysqli_query($conn, $sql1);
}
I need to go to index.php if ever the user tries to send more than 2 of the options.