Mar*_*vin 0 php arrays variables checkbox post
我似乎无法理解为什么我不能通过以下代码传递任何值:
<div class="menu">
Por favor seleccione os conteúdos:
<form name="Categorias" action="Elementos_Descritivos.php" method="post">
<?php
$Categorias = array ("Nome", "Data", "Cliente", "Observacoes");
foreach( $Categorias as $key => $value){
echo "<div class=\"cb-row\">
<label for=\"$value\">$value:</label>
<input id=\"$value\" $value=\"$value\" type=\"checkbox\" value=\"$value\" checked />
</div>";
}
?>
<div class="submit">
<input type="submit" value="Seguinte" />
</div>
</form>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
在Elemento_Descritivos.php页面中,我拥有的所有代码是:
<?php
print("<pre>");
print_r($_POST);
print("</pre>");
?>
Run Code Online (Sandbox Code Playgroud)
它只是输出:
数组()
谢谢.
您需要在所有输入上设置name属性才能使表单发布.该ID当表单提交就不贴了.
<input id=\"$value\" name=\"$value\" .../>
Run Code Online (Sandbox Code Playgroud)
对提交按钮执行相同操作.它允许您确定按下哪个提交按钮,以防您有多个相同的表单.