I’ve got a form with multiple sets of data (which are variable) which I’m attempting to pass into PHP and then for each group of fields, have the individual data into PHP variables ready so I can work with them
My form looks like this :
<input type="hidden" name="group[0]form[][familymember]" value="0">
<input type="checkbox" name="group[0]form[][requestchecked]" value="1">
<textarea name="group[0]form[][requestmessage]" ></textarea>
<input type="hidden" name="group[1]form[][familymember]" value="30">
<input type="checkbox" name="group[1]form[][requestchecked]" value="1">
<textarea name="group[1]form[][requestmessage]" ></textarea>
<input type="hidden" name="group[2]form[][familymember]" value="31">
<input type="checkbox" name="group[2]form[][requestchecked]" value="1">
<textarea name="group[2]form[][requestmessage]"></textarea>
And my PHP code is as below :
foreach ( $_POST['group'] as $group ) {
foreach ( $group['form'] as $member) {
$thisfamilymember = $member['familymember'];
$thisrequestmessage = $member['requestmessage'];
$thisrequestchecked = $member['requestchecked'];
}
echo "<br>thisfamilymember = ".$thisfamilymember;
echo "<br>thisrequestmessage = ".$thisrequestmessage;
echo "<br>thisrequestchecked = ".$thisrequestchecked;
}
However rather than getting 9 lines showing the various data thats been entered in the form, all the echo commands come back showing the variables are empty :
thisfamilymember =
thisrequestmessage =
thisrequestchecked =
thisfamilymember =
thisrequestmessage =
thisrequestchecked =
thisfamilymember =
thisrequestmessage =
thisrequestchecked =
New contributor
Andy Jenkins is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.