Hi there,
I’m using arrays to create checkboxes for a HTML form. Here is the code for one such array:
$custexp2Array = array('1' => 'We are constantly looking to find new ways to improve the overall customer experience.',
'2' => 'There is a team in the business specialising in managing the customer experience.',
'3' => 'There is a dedicated position within the business for customer experience management.',
'4' => 'Customer experience management is something that receives great consideration at a board/strategic level.');
$custexp2Output = '';
foreach($custexp2Array AS $key => $value) {
$checked = (isset($_POST['custexp']) && is_array($_POST['custexp']) && in_array($key, $_POST['custexp'])) ? 'checked' : '' ;
$custexp2Output .= '<input type="checkbox" class="checkbox" name="custexp[]" value="'. $key .'" '. $checked .'>'. $value .'<br />';
}
What I now need to do is to get all the checkboxes that have been checked, turn that into a variable and convert that into a session.
I imagine I’d need to use an if statement (ie if($_SERVER[‘REQUEST_METHOD’] == ‘POST’) ) but what code needs to be included in that statement?
This problem has been troubling me all day so I’d appreciate any help