I have this form in HTML
<form action="" method="post">
<div class="tags">
<label class="tag" for="TAG1"><input type="checkbox" id="TAG1" value="TAG1" name="tags[]">TAG1</label>
<label class="tag" for="TAG2"><input type="checkbox" id="TAG2" value="TAG2" name="tags[]">TAG2</label>
<label class="tag" for="TAG3"><input type="checkbox" id="TAG3" value="TAG3" name="tags[]">TAG3</label>
<label class="tag" for="TAG4"><input type="checkbox" id="TAG4" value="TAG4" name="tags[]">TAG4</label>
<label class="tag" for="TAG5"><input type="checkbox" id="TAG5" value="TAG5" name="tags[]">TAG5</label>
</div>
<button type="submit" name="submit">submit</button>
</form>
Then here is my PHP in brief
if(isset($_POST['submit'])){
$tag = $_POST['tags']
$query = "
SELECT a.title FROM posts a
INNER JOIN tags b ON a.id = b.pid
WHERE b.tag IN (:tag)
";
$stmt = $pdo->prepare($query);
$stmt->execute(['tag' => $tag]);
}
How can i search for multiple selected tags in my code query exactly? I keep getting
Notice: Array to string conversion