I have a while loop that displays 4 checkboxes from $choices with value answer_id from database.
<?php while($row=mysqli_fetch_assoc($choices)){ ?>
<input type="checkbox" name="choices[]" value="<?php echo $row['answer_id']; ?>"><?php echo $row['choice']; ?><?php } ?><?php } ?>
<input type="submit" name="submit" value="submit">
I want to send this array of selected choices to another page and store each of its value in different variables.
if(isset($choices)){
$choice1id = $_POST['choices'];
}
if(isset($choices)){
$choice2id = $_POST['choices'];
}
if(isset($choices)){
$choice3id = $_POST['choices'];
}
if(isset($choices)){
$choice4id = $_POST['choices'];
}
If user has selected 2 checkboxes so its value gets on index 0 and 1 in array and these 2 values get stored in variables choice1id and choice2id on another PHP page. But it says Warning: Undefined variable $choice1id, $choice2id etc. how do I solve this?