I just went through the tutorial on PHP contact forms here but what I have a problem with is if you don’t check the checkboxes, it gives you a PHP error:
Warning: Invalid argument supplied for foreach()
It seems that the user MUST check one of the checkboxes or they will get an error, although the email still gets sent to the specified address. The problem lies in this piece of the PHP script:
foreach($_POST['check'] as $value) {
$check_msg .= "Checked: $value
";
}
I just found a way to fix that problem and I thought I’d share it. It’s a simple modification to the script:
if ($_POST['check']) {
foreach($_POST['check'] as $value) {
$check_msg .= "Checked: $value
";
}
}