Form with Bootstrap does not pass POST

Asked

Viewed 690 times

1

I’m making a login form, it was working perfectly, but then I decided to incorporate some elements of Bootstrap to make it visually more enjoyable. After that, my form stopped sending the POST method. Someone who can help me?

  <div class="col-lg-6" id="page-wrapper">
    <div class="panel panel-primary" Style="width: 400px; margin-left: auto; margin-right: auto;">
        <div class="panel-heading">
             <h3 class="panel-title">Entre com seu usuario e senha</h3>

        </div>
        <div class="panel-body">
            <div class="form-group">
                <form action="index.php" method="post" target="_self" id="login">
                    <div class="form-group input-group"> <span class="input-group-addon">
    <i class="fa fa-user"></i></span> 
                        <input name="user" type="text" autofocus required="required" form="login" size="50" class="form-control" placeholder="Usuario">
                    </div>
                    <div class="form-group input-group"> <span class="input-group-addon">
    <i class="fa fa-key"></i></span> 
                        <input name="senha" type="password" required="required" form="login" size="25" class="form-control" placeholder="Digite sua senha">
                    </div>
                    <p>
                        <?php if (!empty($_GET[ 'falhalogin'])) { echo "<p>Usuário (".$_POST[ 'user']. ") ou senha (".$_POST[ 'senha']. ") inválido.</p>"; } ?></p>
                    <p>
                        <input type="submit" id="entrar" form="login" value="Login" action="index.php" class="btn btn-default">
                </form>
                </p>
            </div>
        </div>
    </div>
</div>
  • Stopped working means what? does not arrive at index.php?

  • That one $_GET['falhalogin'] come from where? seems to be the problem, at least in your form has nothing to get.

  • 1

    I found the problem here... when I was "embedding" the template I got from bootstrap I ended up deleting part of my PHP... then the page was making a redirect to itself.. in this process I lost the POST.... I corrected and the form returned to rotate round!!! thanks guys!

2 answers

1

I found the personal problem! When I decided to move the file I ended up bumping into my PHP, I deleted part of the query to the database... gave error and redirected to the same page, but the form POST was lost!. I ended up thinking that the mistake was in the form.... Thank you!

0


I think it has nothing to do with Bootstrap. The problem should be why you are putting one paragraph inside the other:

<p>                    
<?php    
     if (!empty($_GET['falhalogin'])) { 
              echo "<p>Usuário (".$_POST['user'].") ou senha (".$_POST['senha'].") inválido.</p>";
                }
                ?>

                </p>

Take one of <p> </p> (or that it’s in PHP or what’s in HTML) that should work.

And one of the closures of your paragraph is out of </form>, turn him inside:

<p>

                        <input   type="submit" id="entrar" form="login" value="Login" action="index.php" class="btn btn-default">
                </form>
                </p>

  • Well, I removed all the paragraphs, stay the same.

  • Then take a look at the rray comments on your question.

  • 1

    @Guilhermehd was not my answer that solved your question. You will be able to vote positive when you have 15 rep points. The correct is to put solved in your own answer. I think you need to wait two days for this to be possible, but it’s the right one. You can reverse it by clicking again under the solved sign. I suggest you take the tour of the site, and consult the Help Center to understand how Sopt works. Ah, and welcome! :)

  • 1

    Thanks @gustavox again.

Browser other questions tagged

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