在提交表单时检索动态创建的html输入文本框


retrieving dyamically created html input textboxes when form is submitted

我正在使用php动态创建一个HTML表单。html form上的input框的名称也是动态创建的。当我在动态创建的html form上点击submit并使用方法post将数据推送到服务器时。如何在form的操作页面上调用动态创建的input框的名称?换句话说,如果我有下面这样的代码,当我单击submit时,我如何将input框的名称传递给我的php form

function add_textbox($label, $name) {
    myprint("<label>$label <br><br><input type=text name=$name onblur = '"answerschecker(this.value)'"></label><br><br>");
}

只需使用

<?php    
    if(isset($_POST)){
       foreach($_POST as $value){
          echo $value; //here you will get the values of each field in the form
        }  
    }
 ?>

它将与您的代码一起传递。

如果你想在你的PHP代码中找到它传递给你的名字,你可能想使用一个像我下面要做的语句。

foreach($_POST as $key => $value){
    // The key will be the name of the value passed in this loop.
}