$_POST not returning correctly

Asked

Viewed 37 times

0

Can someone help me? I have a small problem in a registration code that I am studying, I want to make the connection with him in the database, however I am not able to receive the data via POST.

Follow the code and the error:

http://prntscr.com/j6ip0s

http://prntscr.com/j6ip9y

http://prntscr.com/j6ipd7

                                <div class="card-body ">
              <form class="form-group" id="formInscrevase" method="post" action="registro_ml.php">
                <div class="input-group">
                  <span class="input-group-addon">
                    <i class="now-ui-icons users_circle-08"></i>
                  </span>
                  <input type="text" class="form-control" id="usuario" name="usuario" placeholder="Usuário" required="requiored">
                </div>
                <div class="input-group">
                  <span class="input-group-addon">
                    <i class="now-ui-icons text_caps-small"></i>
                  </span>
                  <input type="email" class="form-control" id="email" name="email" placeholder="Email" required="requiored">
                </div>
                <div class="input-group">
                  <span class="input-group-addon">
                    <i class="now-ui-icons ui-1_email-85"></i>
                  </span>
                  <input type="password" class="form-control" id="senha" name="senha" placeholder="Senha" required="requiored">
                </div>
                <div class="form-check text-left">
                  <label class="form-check-label">
                    <input class="form-check-input" type="checkbox">
                    <span class="form-check-sign"></span>
                    Eu concordo
                    <a href="#something">com os termos e condições</a>.
                  </label>
                </div>
              </form>
            </div>
            <div class="card-footer ">
              <a href="registro_ml.php" class="btn btn-primary btn-round btn-lg">Get Started</a>
            </div>
  • If you can post the code, so if the links go out your question may help someone else

  • 2

    The problem is because you created the button as a link that sends to the other page, you must create a Ubmit button and it should be inside the tag "form"

  • 1

    Once you post your code in the question, I create an answer with the change in code for you.

  • Take a tour around https://answall.com/tour

  • Done, edited and put the code!

1 answer

2


Your code is this way, so by clicking submit it simply goes to another page and send the fields via post:

<form action="action_page.php" method="post">
  First name: <input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br>
  <input type="submit" value="Submit">
</form> 
<a href="action_page.php">enviar</a>

And this is the correct way, by putting a Submit button inside the form tag, so it sends all fields via post:

<form action="action_page.php" method="post">
  First name: <input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br>
  <input type="submit" value="Enviar">
</form> 

Using the code posted in the question:

<div class="card-body ">
    <form class="form-group" id="formInscrevase" method="post" action="registro_ml.php">
        <div class="input-group">
            <span class="input-group-addon">
                <i class="now-ui-icons users_circle-08"></i>
            </span>
            <input type="text" class="form-control" id="usuario" name="usuario" placeholder="Usuário" required="requiored">
        </div>
        <div class="input-group">
            <span class="input-group-addon">
                <i class="now-ui-icons text_caps-small"></i>
            </span>
            <input type="email" class="form-control" id="email" name="email" placeholder="Email" required="requiored">
        </div>
        <div class="input-group">
            <span class="input-group-addon">
                <i class="now-ui-icons ui-1_email-85"></i>
            </span>
            <input type="password" class="form-control" id="senha" name="senha" placeholder="Senha" required="requiored">
        </div>
        <div class="form-check text-left">
        <label class="form-check-label">
            <input class="form-check-input" type="checkbox">
            <span class="form-check-sign"></span>
            Eu concordo
            <a href="#something">com os termos e condições</a>.
            </label>
        </div>
        <button type="submit" class="btn btn-primary btn-round btn-lg">Get Started</button>
    </form>
</div>
  • As I am new, I tried to understand your comment and realize in my code, what I missed? http://prntscr.com/j6j94v

  • The button should not be a link( the tag 'a' ) but an input of type Submit or a button of type Submit.

  • I edited the answer by placing your code with a button like Submit.

  • 1

    Ah!! Got it, thank you very much!! D

Browser other questions tagged

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