I do not succeed in sending the values of multiple checkboxes from a form with PHP mail.
This is piece of my form with the checkboxes:
<input type="checkbox" name="registercheckbox[]" value="saturday-16:00">
<input type="checkbox" name="registercheckbox[]" value="saturday-17:00">
<input type="checkbox" name="registercheckbox[]" value="saturday-18:00">
In my php file i use this to settle the values form the multiple checkboxes:
$selected_checkbox = $_POST['registercheckbox'];
if(empty($selected_checkbox)) {
echo("you have to chose at least 1 checkbox!");
}
else {
$N = count($selected_checkbox);
echo('Your preferences are: ');
for($i=0; $i < $N; $i++) {
$preferences = $selected_checkbox[$i];
echo($selected_checkbox[$i] . " ");
}
}
In the body preparing for the email i use this:
$body .= "Preferences: ";
$body .= $preferences;
$body .= "\n";
and to send the mail:
mail($to, $subject, $body, $headers)
The echoes are working fine: it echoes every selected value of the checkboxes But sending the email: it only sends the last checked checkbox value
What am I doing wrong?