Return query on same page

Asked

Viewed 3,176 times

3

I need to make a query to the Bank and return the value of the variables on the same page PHP. But even the test to try to understand logic didn’t work:

<html>
<form name="registar" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">

sua form bLA BLA BLA

<input type="submit" class="submit" name="submit"  value="Enviar registo" />
</form>

<?
if (!$_POST['submit']) {

echo "bla bla bla SEU nome, pass";

} else {

echo "AGUARDANDO";

}
?>

</html>

In that case he just goes into "WAITING".

Can someone give me an idea?

  • The negation is reversing the result, if it has value(true) deny it, then it falls into Else, can make a test let the empty value will fall into the if.

1 answer

4


Change the condition of your if for something like this:

<html>

    <form name="registar" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
        <input type="hidden" name="oculto" value="teste">
        <input type="submit" class="submit" name="submit"  value="Enviar registo" />
    </form>

    <?php
    if (isset($_POST['submit'])) {
        var_dump($_POST);
    } else {
        echo "AGUARDANDO";
    }
    ?>

</html>

The isset() checks whether there is a $_POST['submit'] the way it is it will always go to the false condition.

  • Exactly that, thank you very much!

  • 2

    Just to complement, note @Diego that you only used <? to write php, depending on the version of the server this way the server will not interpret. Always use <?php to start php code just like @gmsantos used it. Tip to not have future problems.

  • Well noted @Skywalker. In avoid the use of short tags to not have future problems. I believe that there are some questions here with problems related to this.

Browser other questions tagged

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