-4

I'm doing a webpage for a university task but I'm having problems with this code.

if ($_POST["id_temporada"]>0 and $_POST["query"]=="") {
    $consulta="select * from obras where id_temporada=".$_POST["id_temporada"];
}

also with this one

if ($_POST["id_temporada"]>0 and $_POST["query"]<>"") {
    $consulta="select * from obras where temporada=".$_POST["id_temporada"]." and nombre
    like '%".$_POST["query"]."%'";
}

In both cases, I have the notice I posted on the title. What should i do?

j08691
  • 204,283
  • 31
  • 260
  • 272

1 Answers1

0

You have to check if the index exists with isset($variable) before accessing that index.

$_POST["query"]=="" should be (!isset($_POST["query"])||$_POST["query"]=="")

Lukas T
  • 116
  • 2
  • 8