email - PHP - checkbox value display in E-mail responder

Solution:

Should be

if(isset($_POST['document']) && count($_POST['document']) > 0) {
    foreach($_POST['document'] as $doc){
        if(isset($documents[$doc])){
            $document = implode(", ",$_POST['document']);
            $message = "
            ŠKOLENIE: $document
            ";
        }
    }
}

Answer

Solution:

You don't have such a variable as $post, but you try to use it twice. Replace it with $_POST and your form will work.

This:

$document = implode(", ",$post['document']);

Replace with this:

$document = implode(", ",$_POST['document']);

And it should work.

Some hints:

  1. Properly configured IDE will let you know about such errors as an undeclared variable. Use PHPStorm (commercial) or VSCode (free).
  2. Don't close php tag (?>) at the end of your file (PSR2):

The closing ?> tag MUST be omitted from files containing only PHP.

  1. Don't use the same identifier (id) multiple times. The id should be unique in the entire HTML document.

Edit: // As someone has mentioned in the comments, you don't have a closing tag for <form> tag, but I assumed that you pasted only a part of your HTML document. Otherwise, you should correct that as well.

Source