为什么我的php代码中存在身份不明的索引

时间:2019-06-26 05:38:13

标签: php html

我尝试了很多调试该方法的方法,也无法在线找到答案,所以我在这里发布了我的问题,希望您可以找到解决方法。所以我的问题是我已经在每个单选按钮上设置了变量,但是一旦提交表单,它就不会出现在另一个php文件中,而是输出错误“ Undefined index”。我的代码可能出什么问题了?预先谢谢你!

index.php

    <form action="answers.php" method="post">
    <div class="row mt-3">
        <div class="col-md-2 ml-5">

        <?php 
        $x = 1;
        while ($x<= 20) {
        ?>
        <?php echo $x; ?>
        <label for="" class="radio-inline"><input type="radio" name="no<?php echo $x1; ?>">A</label>
        <label for="" class="radio-inline"><input type="radio" name="no<?php echo $x1; ?>">B</label>
        <label for="" class="radio-inline"><input type="radio" name="no<?php echo $x1; ?>">C</label>
        <label for="" class="radio-inline"><input type="radio" name="no<?php echo $x1; ?>">D</label>
        <br>
        <?php $x++; }; ?>


        </div>
</div>
    <input type="submit" value="Submit Answers" class="btn btn-success">
</form>

answers.php

    <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Answers</title>
</head>
<body>
    <label>1</label> <?php echo $_POST['no1']; ?>
</body>
</html>

0 个答案:

没有答案
相关问题