Undefined index: txtnum in C: xampp htdocs factor.php on line 2, can anyone help with this error?

Asked

Viewed 34 times

0

follows the codes:

<html>
<head>
    <title>Fatoração</title>
</head>
<body>
    <form method="post" action="fator.php">
        Numero: <input type="text" name="txtnum"><br>
        <input type="submit" name="Calcular">
    </form>
</body>
</html>

<?php
    $num = $_POST["txtnum"];
    $variavel = $num;
    $fatorial = $variavel;

    while ($variavel > 1) {
        $fatorial = $fatorial*($variavel-1);
        $variavel--;
    }
    echo "Número fatorado: $fatorial";
?>
  • I withdrew, continue giving the same error.

  • At first execution $_POST["txtnum"] there is, um isset() in it already solves.

  • try to use isset() on the button Calcular

  • When I give the isset it returns nothing, and testing with the real Empty(empty variable).

No answers

Browser other questions tagged

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