【问题标题】:Form submission unidentified index表单提交不明索引
【发布时间】:2015-12-15 05:23:44
【问题描述】:

我尝试在同一页面上提交表单,但出现此错误:

未定义索引:text1

还有:

未定义索引:text2。

这是我正在使用的代码:

<?php include('includes/header.php') ?>
<section class="login">
    <?php
    if (isset($_POST['submitbtn'])) {
        $text1 = $_POST['text1'];
        $text2 = $_POST['text2'];
        echo "Success! You entered: " . $text1 . "<br>";
        echo "Success! You entered: " . $text2 . "<br>";
    } else {
        ?>
        <form action="" method="post">
            <p><label>Text1:</label><input type="text" name"text1"/></p>
            <p><label>Text2:</label><input type="text" name"text2"/></p>
            <input type="submit" name="submitbtn"/>
        </form>

    <?php } ?>
</section>
<?php include('includes/footer.php') ?> 
  • header.php 包含一个 html 导航,它打开一个连接到 数据库。
  • footer.php 有页脚并关闭连接。

我做错了什么?还有在同一页面上提交表单的更好方法吗?

【问题讨论】:

    标签: php html forms submit


    【解决方案1】:

    name"text1" 中忘记=。会是

     <p><label>Text1:</label><input type="text" name="text1"/></p>
     <p><label>Text2:</label><input type="text" name="text2"/></p>
    

    【讨论】:

      猜你喜欢
      • 2015-09-29
      • 2014-02-15
      • 1970-01-01
      • 1970-01-01
      • 2011-06-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多