Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 表格提交不明索引_Php_Html_Forms_Submit - Fatal编程技术网

Php 表格提交不明索引

Php 表格提交不明索引,php,html,forms,submit,Php,Html,Forms,Submit,我试图在同一页上提交表单,但出现以下错误: 未定义索引:text1 以及: 未定义的索引:text2 以下是我正在使用的代码: <?php include('includes/header.php') ?> <section class="login"> <?php if (isset($_POST['submitbtn'])) { $text1 = $_POST['text1']; $text2 = $_POST['

我试图在同一页上提交表单,但出现以下错误:

未定义索引: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') ?> 

正文1:

文本2:

  • php包含一个html导航,它打开到的连接 数据库
  • php具有页脚并关闭连接

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

忘记
=
中的
名称“text1”
。是的

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

文本2: