i am knew to php, and i want to know if there is a way to show the input based on the names that were checked, for example i have cat, dog and fish, if i choose dog and fish, i have to type the names of those animals.
here is the code to ask what animal do you have, and by checking and submit, it appears on the other page
<body>
<?php
$check_list[]=isset($_GET["check_list"])?$_GET["check_list"]:"";
if(!empty($_POST['check_list'])) {
foreach($_POST['check_list'] as $check) {
echo $check;
}
}
?>
<form action="names.php" method="POST">
<h1>choose the animals you have, and type their names</h1>
<input type="checkbox" name="check_list[]" value="cat">
cat
<br>
<input type="checkbox" name="check_list[]" value="dog" >
dog
<br>
<input type="checkbox" name="check_list[]" value="fish" >
fish
<br>
<input type="submit" value="next">
</form>
and here is the other page, that show what animals you have selected, and on this page i want to show the inputs based on the checked
<body>
<?php
echo '<h3>You have select following animals</h3>';
foreach ( $_POST ["check_list"] as $animals )
echo '<p>' . $animals . '</p>';
?>