My POST is not sending anything

1

NO HTML:

    <form method="post"  action="../../../consulta.php">
    <input type="text" class="form-control"  name="login" id="flogin" 
           placeholder="Insira o seu Login">
    <input type="submit" name="send" id="mandar" class="btn btn-success btn- 
           block" onclick="" value="Entrar">
   </form>

NO PHP

if (!empty($_POST)) {

    if (isset($_POST['login'])) {

        if (!empty($_POST['login'])) {
          $filtro = $_POST['login'];

          // aqui caso tudo estiver certo
         } else {
          echo "Por favor, preencha o seu login";
         }

    } else {
       echo "O campo 'login' não existe na variável $_POST";
    }

} else {

  echo "Não houve submit no formulário";

}

It falls into the last echo where it says there was no submit in form, where did I go wrong? I've tried everything, and it's not right, it does not show me anything even when I type a value, help me. Everything is inside the body and html tag, the error for some reason is there

    
asked by anonymous 04.04.2018 / 14:11

1 answer

2

There are some openings / closures of if wrong in your code.

This is correct:

<?php 
if (!empty($_POST)) {

    if (isset($_POST['login'])) {

        if (!empty($_POST['login'])) {
            $filtro = $_POST['login'];
            echo "ok";
            // aqui caso tudo estiver certo
        } else {
            echo "Por favor, preencha o seu login";
        }
    }
} else {

    echo "Não houve submit no formulário";

}
?>
    
04.04.2018 / 14:18