注意错误:无法直接访问$ _POST

时间:2015-08-19 08:10:39

标签: php forms validation error-handling

当我尝试通过Netbeans运行时,它会显示通知错误,但表单显示正常且工作正常。为什么会显示错误?

 
<html>

    <head>
        <title>Form Validation with Multiplication</title>
    </head>

    <body>

    <?php

        if(!empty($errors))
        {
            echo join('<br />', $errors);
        } 
        elseif(isset($_POST)) 
        {
            $value = ($_POST['number1'] * $_POST['number2']);
            echo 'The Multiplication is: '.$value.'<br />';
        }
    ?>

    <form method="post" action="">
        Enter the Number 1 <input type="text" name="number1" value="<?php print $_POST['number1']; ?>" size="5" maxlength="5" /><br />
        Enter the Number 2 <input type="text" name="number2" value="<?php print $_POST['number2']; ?>" size="5" maxlength="5" /><br />
        <input type="submit" name="submit" value="submit" />
    </form>

    </body>

</html>

0 个答案:

没有答案