took a year off as a newbie and wanted to try again. I am simply trying to read multiple checkbox entries. It looks like the values are not loading into the global POST or I am not properly accessing them as I only get the last checkbox value when I can get the code to work. mostly I get the error: Warning : foreach() argument must be of type array|object, string given in /home/funkandg/!sites/mike/combolisk.org/www/mikedocs/pics/annaappend.php on line 7
My simple form:
<html>
<head>
<style>
th, td {
border: 1px solid black;
}
</style>
</head>
<body>
<div>
<h1>Select multiple</h1>
<p>Please select the checkboxes for articles you want displayed. Continue to the text and use the audio button to listen.</p>
<form action = "annaappend.php" method = "post">
<button type = "submit" name = "submit">Load</button>
<table style="width:100%">
<tr>
<th>Check</th>
<th>#</th>
<th>Approximate Date</th>
<th>Title</th>
</tr>
<tr>
<td><input type = "checkbox" name = "check" value = "file 1">file 1</td>
<td>Article #1</td>
<td>1/1/2014</td>
<td>My Dear Archbishop George</td>
</tr>
<tr>
<td><input type = "checkbox" name = "check" value = "file 2">file 2</td>
<td>Article #2</td>
<td>6/5/14</td>
<td>The Nut is Cracked</td>
</tr>
<tr>
<td><input type = "checkbox" name = "check" value = "file 3">file 3</td>
<td>Article #3</td>
<td>6/5/14</td>
<td>For a Deeper Understanding</td>
</tr>
</table>
<br><br><br><br><br><br>
<input type = "text" name="hidden" placeholder = "not used">
</form>
</div>
</body>
</html>
The php copied from an example changing just the variable$
<?php
//retrieve playlist from checkboxex
if (isset($_POST['check']))
{
if(!empty($_POST['check']))
{
foreach($_POST['check'] as $fname)
{
echo $fname. "<br>";
echo "end of file";
}
}
}
echo "Thank you. Use the button above the text to listen";
?>
Your help is greatly appreciated.