```
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<form action="process.php" method="post">
<input type="checkbox" name="top[]" value="pep">Pepperoni<br>
<input type="checkbox" name="top[]" value="msh">Mushrooms<br>
<input type="checkbox" name="top[]" value="olv">Olives<br>
<input type="submit" name="submit">
</form>
</body>
</html>
``` ```
<?php
if (isset($_POST['submit'])) {
$toppings = filter_input (INPUT_POST, 'top', FILTER_SANITIZE_SPECIAL_CHARS, FILTER_REQUIRE_ARRAY);
if (toppings !==null) {
foreach (toppings as $key => $value) {
echo $key .'=' .$value . '<br>';
}
} else {
echo 'No toppings selected.';
}
}
?>
results on my local host
Warning: Use of undefined constant toppings - assumed 'toppings' (this will throw an Error in a future version of PHP) in C:\xampp\htdocs\Toppings_Display\process.php on line 4
Warning: Use of undefined constant toppings - assumed 'toppings' (this will throw an Error in a future version of PHP) in C:\xampp\htdocs\Toppings_Display\process.php on line 5
Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\Toppings_Display\process.php on line 5