我正在使用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.
}