所以..我遇到动态表单问题/ $_POST
...我需要通过if(isset($_POST['Submit_bc3']))
中的单选按钮来回显我选择的图像......但是它不起作用,我不明白..我怎么能让这个问题消失?代码:
<?php
$image_url = $user['image_location'];
$directory2 = "../../../login_/assets/playercards/";
$images2 = glob($directory2 . "*.jpg");
if (isset($_POST['Submit_bc3'])) {
echo $image2;
}else{
foreach($images2 as $image2)
{
echo '<img src="'.$image2.'" border="0" height="81px" width="156px" />';
echo "<input type='Radio' name='".$image2."' value=''></input>";
}
}
?>
<button type="submit" class="button" name="Submit_bc3" data-bind="vortexExternalLinkAction: ''">_LETS_GO</button>
答案 0 :(得分:1)
$image2
中的变量之后回显它之前,代码中不存在 isset
。
答案 1 :(得分:1)
您需要为所有按钮指定相同名称,以便它们成为单个单选按钮组。然后在$_POST
中使用该名称来获取提交后的值。
if (isset($_POST['Submit_bc3'])) {
echo $_POST['image2'];
}else{
foreach($images2 as $image2)
{
echo '<img src="'.$image2.'" border="0" height="81px" width="156px" />';
echo "<input type='Radio' name='image2' value='".htmlentities($image2)."'></input>";
}
}