Question: I would like a help, I converted the input string from date to array and if I do not input for example 05/26/2019, all 3 fields did an explode to flip an array, then this error occurs. what can I do?

escola.php

```
 <form method="POST" class="PesquisarData">
    <h5>Pesquisar Data:</h5>
    <input type="text" id="data" name="data" class="selectData">
    <input type="submit" value="Pesquisar" class="buttonData"><br/>
 </form>

if (!empty($_POST['data'])) {
        $_POST['disciplina'] = "";
        $_POST['professor'] = "";

        $data = explode('/', addslashes($_POST['data']));
        $data = $data[2].'-'.$data[1].'-'.$data[0];
        $sqlm = "SELECT * FROM {$pfx}Material WHERE Data LIKE CONCAT('%',?,'%') ORDER BY Data DESC";
        $qrym = $conn->prepare($sqlm);
        $qrym->bindParam(1, $data);
        $qrym->execute() or die('Ocorreu um erro em uma operação do banco de dados: VL0002.2');
}

```

Answer: 
Check that `$data` has 3 elements before trying to use it.

```
$data = explode('/', addslashes($_POST['data']));
if (count($data) != 3) {
    die('Invalid date ' . $_POST['data']);
}
$data = $data[2].'-'.$data[1].'-'.$data[0];

```
Your programming assumes that the user also uses the slash that you explode! You have to check before the sender whether he slashed these 2 - which you require - also enters