My POST is not sending anything

Asked

Viewed 134 times

1

IN 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>

IN 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";

}

He falls on the last echo Where does it say there was no Ubmit on the form, where did I go wrong? I’ve tried everything, and it doesn’t show me anything even when I type a number, help me. It’s all inside the body and html tag, the error for some reason is there

  • Press F12 and check on the tab Network the request POST; Check if any content arrives using var_dump(fgets(STDIN));

  • You’re returning me Bool(false), and there’s nothing on F12(Network)

  • Could you put one more piece of html? I tested your code here and it worked perfectly

  • That’s just it, I guess I’ll have to stay here a little while longer to see where the mistake is

  • You are using Javascript to send the POST?

  • Same html form, same form

  • you are using local server? Which?

  • I think I already found the error, has nothing to do with the codes I put here, the error itself was caused by an if that did not think had to do with the problem

Show 3 more comments

1 answer

2


It has openings/closures of if wrong in your code.

That way it’s right:

<?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";

}
?>
  • Already fixed, the problem still persists, can not see problems with the form in html.

  • Does it generate an error? Or does it just fall into echo "Não houve submit...?

  • I just fell in the "There was no Submit"

  • What can not understand, It is all right and does not send anything by POST

  • give a var_dump($_POST) and see what’s coming there.

  • Check the action try to change which file you are sending and see what comes

  • This is going exactly to the.php query that is 3 levels above ;/

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.