store values of multiple checkboxes in one array and send it to another php page

  php

I have a while loop that displays 4 checkboxes from $choices with value answer_id from database.

<?php while($row=mysqli_fetch_assoc($choices)){ ?>

“>

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 ?

Source: Ask PHP

LEAVE A COMMENT