-4

i want to make a form with inputs. I have a while for inputs texts.

            <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>

And this is the code for POST

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

Error is:

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
Nemus
  • 3,879
  • 12
  • 38
  • 57
Vlad S
  • 11
  • 4

2 Answers2

1

Try this

<input type="text" class="form-control" id="formGroupExampleInput" id="app<?=$i?>" name="app<?=$i?>" placeholder="<?=$intr?>" required>
Panup Pong
  • 1,871
  • 2
  • 22
  • 44
0

Here whatever you trying yo make id and name are not proper

One more thing each tag should have only one id attribute so remove one in below... i have removed id="app"

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

to

<input type="text" class="form-control" id="formGroupExampleInput"  name="app<?=$i?>" placeholder="<?=$intr?>" required>
K.B
  • 885
  • 5
  • 10