Php 以字符串形式携带数组元素的html表单按钮
我希望能够使用HTML表单按钮将Php 以字符串形式携带数组元素的html表单按钮,php,html,forms,button,session-variables,Php,Html,Forms,Button,Session Variables,我希望能够使用HTML表单按钮将$\u POST['v'](string)带到delete.php $directory = "exports/"; $contents = scandir($directory,1); foreach($contents as $k => $v) { if ($v != '.' && $v != '..') { echo "<a href=\"$directory" . $v . "\">".$v."</a>"
$\u POST['v']
(string)带到delete.php
$directory = "exports/";
$contents = scandir($directory,1);
foreach($contents as $k => $v) {
if ($v != '.' && $v != '..') {
echo "<a href=\"$directory" . $v . "\">".$v."</a>";
echo "<form action=\"delete.php\" method=\"post\"><a class=\"buttonnohover\"><input type=\"submit\" class=\"button\" name=\"v\" value=\"Delete\" /></form> <br>";
}
}
$directory=“exports/”;
$contents=scandir($directory,1);
foreach($k=>v的内容){
如果($v!='.&&$v!='..'){
回声“;
回声“
”;
}
}
此时,submit按钮只是返回字符串(6)“Delete”。我希望$u POST['v']等于每个按钮上携带的每个$v(目录中的文件名)
我做得不对的是什么?当您想使用表单获取要删除的
$v
的值时,可以使用隐藏输入:
echo '<a href="'.$directory.$v.'">'.$v.'</a>';
echo '<form action="delete.php method="post">
<input type="hidden" name="v" value="'.$v.'" />
<a class="buttonnohover"><input type="submit" class="button" name="submit" value="Delete" />
</form><br>';
echo';
echo'您的问题是什么?我想您希望提交按钮有一个值,对吗?