未定义的变量 - 来自while输入的POST

时间:2017-11-30 09:49:39

标签: php

我想制作一个带输入的表格。我有一段时间用于输入文本。

            <form class="form-horizontal new-lg-form" id="loginform" method="post">
        <?php $i = '1'; while($i <= '10') { $ids = 'factionQ'.$i.'';$intr = $row[$ids]; $i++;?>
          <div class="form-group">
            <label for="formGroupExampleInput">Intrebarea #<?=$i?> =></label>
            <input type="text" class="form-control" id="formGroupExampleInput" id="app".$i."" name="app".$i."" placeholder="<?=$intr?>" required>
          </div>
       <?php } ?>
       <center><button class="btn btn-success" name="btn-apply" type="submit"> Aplica!</button></center> </form>

这是POST的代码

      if(isset($_POST['btn-apply'])) {
    $i = '1'; while($i <= '10') { 
      $appos = filtrare($_POST['app'.$i.'']);
      echo $appos;
      $i++;
    }
  }

错误是:

Notice: Undefined index: app1 in D:\xampp\htdocs\panelrog\fapply.php on line 13

Notice: Undefined index: app2 in D:\xampp\htdocs\panelrog\fapply.php on line 13

Notice: Undefined index: app3 in D:\xampp\htdocs\panelrog\fapply.php on line 13

Notice: Undefined index: app4 in D:\xampp\htdocs\panelrog\fapply.php on line 13

Notice: Undefined index: app5 in D:\xampp\htdocs\panelrog\fapply.php on line 13

Notice: Undefined index: app6 in D:\xampp\htdocs\panelrog\fapply.php on line 13

Notice: Undefined index: app7 in D:\xampp\htdocs\panelrog\fapply.php on line 13

Notice: Undefined index: app8 in D:\xampp\htdocs\panelrog\fapply.php on line 13

Notice: Undefined index: app9 in D:\xampp\htdocs\panelrog\fapply.php on line 13

Notice: Undefined index: app10 in D:\xampp\htdocs\panelrog\fapply.php on line 13

2 个答案:

答案 0 :(得分:1)

试试这个

<input type="text" class="form-control" id="formGroupExampleInput" id="app<?=$i?>" name="app<?=$i?>" placeholder="<?=$intr?>" required>

答案 1 :(得分:0)

这里无论你想要什么,你的身份和姓名都不合适

每个标记应该只有一个id属性,所以删除下面的一个...我删除了id =&#34; app&#34;

 <input type="text" class="form-control" id="formGroupExampleInput" id="app".$i."" name="app".$i."" placeholder="<?=$intr?>" required>

<input type="text" class="form-control" id="formGroupExampleInput"  name="app<?=$i?>" placeholder="<?=$intr?>" required>