因此,我正在尝试使用具有相同列表的下载按钮和删除按钮。 目前是这样的:
echo '<form action="download.php" method="get" enctype="multipart/form-data">';
foreach ($files as $file) {
echo '<input type="checkbox" name="download" value="' . $file . '" /> ' .
$file . '<br /><br />';
}
echo '<input type="submit" class="btn btn-secondary" value="Download" > ' . '</form>';
echo nl2br (" \n ");
echo nl2br (" \n ");
echo (" <strong>Delete</strong><br/>Choose only<strong> 1 </strong>! ");
echo nl2br (" \n ");
echo nl2br (" \n ");
echo '<form action="delete.php" method="get" enctype="multipart/form-data">';
foreach ($files as $file) {
echo '<input type="checkbox" name="download" value="' . $file . '" /> ' . $file . '<br /><br />';
}
echo '<input type="submit" class="btn btn-secondary" value="Delete" />' .
'</form>';
但是我希望它具有这样的东西:
foreach ($files as $file) {
echo '<form action="download.php" method="get" enctype="multipart/form-data">';
foreach ($files as $file) {
echo '<input type="checkbox" name="download" value="' . $file . '" /> ' . $file . '<br /><br />';
}
echo '<input type="submit" class="btn btn-secondary" value="Download" > ' .
echo '<input type="submit" class="btn btn-secondary" value="Delete" />' . '</form>';
foreach ($files as $file) {
$file . '<br /><br />';
}
'</form>';
“删除按钮”应转到delete.php,下载按钮应转到具有相同“表单”的“ download.php”。
答案 0 :(得分:2)
给每个input
一个name
属性。仅单击的输入的名称属性会发送到服务器。
<input type="submit" name="download" value="Download">
<input type="submit" name="delete" value="Delete">
然后(在后端文件中)
<?php
if (isset($_POST['download'])) {
# download-button was clicked
}
elseif (isset($_POST['delete'])) {
# delete-button was clicked
}
?>