I am having trouble displaying the correct answer/value picked in the contact form. The email received will only show C as an answer and not the picked choice.
<tr>
<td><label for="gategory">Lemosine</label></td>
<td><input type="checkbox" name="carchoice[]" value="A" /><td>
</tr>
<tr>
<td><label for="gategory">Mini</label></td>
<td><input type="checkbox" name="carchoice[]" value="B" /></td>
</tr>
<tr>
<td><label for="gategory">Van</label></td>
<td><input type="checkbox" name="carchoice[]" value="C" /></td>
</tr>
<tr>
<td><label for="gategory">Off-Road</label></td>
<td><input type="checkbox" name="carchoice[]" value="D" /></td>
</tr>
<tr>
<td><label for="gategory">Station-car</label></td>
<td><input type="checkbox" name="carchoice[]" value="E" /></td>
</tr>
And the PHP code
$check_box_values = "Check box value: ";
if(isset($_POST['carchoice'])){
foreach($_POST['carchoice'] as $value){
$check_box_values .= $value;
$check_box_values .= ', ';
}
}
$msg=
'Name: '.$_POST['name'].'<br />
Email: '.$_POST['email'].'<br />
IP: '.$_SERVER['REMOTE_ADDR'].'<br /><br />
IP: '.$check_box_values['carchoice[]'].'<br /><br />
Message:<br /><br />
'.nl2br($_POST['message']).'
';
This is what i get in the email
Name: awdawd aw
Email: adasda@live.dk
IP: 195.249.185.254
IP: C
Message:
awdawdawdd awd awdawd awd awd
Don't understand what i going wrong here?