fork download
  1. <?php
  2. if($_SERVER['REQUEST_METHOD'] == 'POST')
  3. {
  4.  
  5. echo "<h2>Answers for participants</h2>";
  6. for($index=0;$index < count($_POST['participant']); $index++) {
  7. echo "<p>{$_POST['participant'][$index]['name']} {$_POST['participant'][$index]['surname']}</p>";
  8. for($qindex=0;$qindex < count($_POST['participant'][$index]['questions']); $qindex++) {
  9.  
  10. $id = $_POST['participant'][$index]['questions'][$qindex];
  11. foreach($id['question_id'] as $key => $question) {
  12. echo "<p>Question ID: $key answer {$question['answer']}</p>";
  13. }
  14. }
  15. }
  16. }
  17.  
  18. ?>
  19. <form method="post">
  20.  
  21. <h6>Participant - 1 - general</h6>
  22.  
  23. <div class="form-group font-size-sm">
  24. <label for="namegeneral_1"
  25. class="text-gray">Name</label>
  26. <input type="text" required id="namegeneral_1"
  27. name="participant[0][name]"
  28. class="form-control" value="Jerry">
  29. </div>
  30. <div class="form-group font-size-sm">
  31. <label for="surnamegeneral_1"
  32. class="text-gray">Surname</label>
  33. <input type="text" required id="surnamegeneral_1"
  34. class="form-control"
  35. name="participant[0][surname]" value="Bostick">
  36. </div>
  37.  
  38. <div class="form-group">
  39. <label for="participant_question">Phone</label>
  40.  
  41. <input type='phone' name='participant[0][questions][][question_id][1][answer]' class='form-control' value="909-188-7522" >
  42. <!-- Pretend additional question for meal -->
  43. <input type='text' name='participant[0][questions][][question_id][5][answer]' class='form-control' value="Steak" >
  44. </div>
  45.  
  46. <input type="hidden" name="participant[1][rtypes]" value="1"/>
  47.  
  48. <h6>Participant - 2 - general</h6>
  49. <div class="form-group font-size-sm">
  50. <label for="namegeneral_2"
  51. class="text-gray">Name</label>
  52. <input type="text" required id="namegeneral_2"
  53. name="participant[1][name]"
  54. class="form-control" value="Tammy">
  55. </div>
  56. <div class="form-group font-size-sm">
  57. <label for="surnamegeneral_2"
  58. class="text-gray">Surname</label>
  59. <input type="text" required id="surnamegeneral_2"
  60. class="form-control"
  61. name="participant[1][surname]" value="Wallace">
  62. </div>
  63.  
  64. <div class="form-group">
  65. <label for="participant_question">Phone</label>
  66. <input type='phone' name='participant[1][questions][][question_id][1][answer]' class='form-control' value="909-872-1232" >
  67. <!-- Pretend additional question for meal -->
  68. <input type='phone' name='participant[1][questions][][question_id][5][answer]' class='form-control' value="Chicken" >
  69. <input type="hidden"
  70. name="participant_question_required[]"
  71. value="1">
  72. <input type="hidden"
  73. value="1"
  74. name="participant[1][][question_id]"/>
  75. </div>
  76.  
  77.  
  78.  
  79. <input type="hidden" name="participant[2][rtypes]" value="1"/>
  80.  
  81. <input type="submit" class="btn btn-primary" value="Register"/>
  82. </form>
  83.  
Success #stdin #stdout #stderr 0.04s 23436KB
stdin
Standard input is empty
stdout
<form method="post">

    <h6>Participant - 1 - general</h6>

    <div class="form-group font-size-sm">
        <label for="namegeneral_1"
               class="text-gray">Name</label>
        <input type="text" required id="namegeneral_1"
               name="participant[0][name]"
               class="form-control" value="Jerry">
    </div>
    <div class="form-group font-size-sm">
        <label for="surnamegeneral_1"
               class="text-gray">Surname</label>
        <input type="text" required id="surnamegeneral_1"
               class="form-control"
               name="participant[0][surname]" value="Bostick">
    </div>

    <div class="form-group">
        <label for="participant_question">Phone</label>

        <input type='phone' name='participant[0][questions][][question_id][1][answer]' class='form-control' value="909-188-7522" >
        <!-- Pretend additional question for meal -->
        <input type='text' name='participant[0][questions][][question_id][5][answer]' class='form-control' value="Steak" >
    </div>

    <input type="hidden" name="participant[1][rtypes]" value="1"/>

    <h6>Participant - 2 - general</h6>
    <div class="form-group font-size-sm">
        <label for="namegeneral_2"
               class="text-gray">Name</label>
        <input type="text" required id="namegeneral_2"
               name="participant[1][name]"
               class="form-control" value="Tammy">
    </div>
    <div class="form-group font-size-sm">
        <label for="surnamegeneral_2"
               class="text-gray">Surname</label>
        <input type="text" required id="surnamegeneral_2"
               class="form-control"
               name="participant[1][surname]" value="Wallace">
    </div>

    <div class="form-group">
        <label for="participant_question">Phone</label>
        <input type='phone' name='participant[1][questions][][question_id][1][answer]' class='form-control' value="909-872-1232" >
        <!-- Pretend additional question for meal -->
        <input type='phone' name='participant[1][questions][][question_id][5][answer]' class='form-control' value="Chicken" >
        <input type="hidden"
               name="participant_question_required[]"
               value="1">
        <input type="hidden"
               value="1"
               name="participant[1][][question_id]"/>
    </div>



    <input type="hidden" name="participant[2][rtypes]" value="1"/>

    <input type="submit" class="btn btn-primary" value="Register"/>
</form>
stderr
PHP Notice:  Undefined index: REQUEST_METHOD in /home/99sSys/prog.php on line 2