访问 php isset 函数中的提交按钮



我正在尝试访问isset函数中的输入类型"submit"。 当我按下"删除"图标时,将执行以下代码。然后,如果您确实要删除此条目,它会显示显示的问题。如何访问这两个按钮?嵌套的 isset 函数有效吗?感谢您的帮助

if(isset($_GET['delete_id'])){

echo 'Do you want to delete '.$_GET['delete_id']. '? <br>';


echo '<input type="submit" name="delete_yes" value="Yes" style="margin: 10px; position: absolute; top: 60px; "></input>';   
echo '<input type="submit" name="delete_no" value="No" style="margin: 10px; position: absolute; top: 60px; left: 55px; "></input>';

}
if(isset($_GET['delete_yes'])){
echo 'deleted';
}

您可以将按钮包装在将 id 作为隐藏值传递的表单中:

if(isset($_GET['delete_id'])){
echo 'Do you want to delete '.$_GET['delete_id']. '? <br>';
echo '<form method="get">';
echo '<input type="hidden" name="delete_id" value="'.$_GET['delete_id'].'" />';
echo '<input type="submit" name="delete_yes" value="Yes" style="margin: 10px; position: absolute; top: 60px; "></input>';
echo '<input type="submit" name="delete_no" value="No" style="margin: 10px; position: absolute; top: 60px; left: 55px; "></input>';
echo '</form>';
}
if(isset($_GET['delete_yes'])){
echo 'deleted '.$_GET['delete_id'];
}

最新更新