It is necessary to check if the user wrote 2 or more words, if less, then an error should be generated. This must be done using the "explode" method.
my code
<input type="text" name="films" class="form-control mb-3">
<?php
$films = $_POST['films'];
if(explode(',', $films) < 2) {
echo 'error';
} else {
echo $films;
}
>Solution :
Use the count method to count the explode result:
if (count(explode(',', $films)) < 2)
...