I have looked at multiple examples of the implode array and cannot work out why I cannot see if multiple check boxes are selected.
Can I pleas get assistance as to what
Try :-
$check_msg = implode(", ", $_POST['check']);
If you're using <input name="check[]" type="checkbox" />
, you'll already get an array in $_POST['check']
. You're having an error because you're trying to concatenate an array $check_msg
in a string $body
.
You need to do the following:
$check = isset($_POST['check']) ? $_POST['check'] : '';
$check_msg = is_array($check) ? implode(", ", $check) : '';
$body = "F-Name: ".$name_field ."\r\n". "L-Name: ".$secondname_field ."\r\n". "Email: ".$email_field ."\r\n". "Phone: ".$phone_field ."\r\n". "Contact-Method: ".$dropdown ."\r\n". "Message: ".$message ."\r\n". $check_msg;
If $_POST['check']
isn't an array, you won't get a PHP error.