【发布时间】:2012-01-31 18:15:31
【问题描述】:
所以我试图通过表单提交一个变量和变量的名称。我将按钮从提交切换到按钮,因为我需要额外的验证。
不管怎样,现在是按钮:
<button type="button" onclick="subForm()" name="del" id="deletebutton" value="'.$org.'">Delete</button>
这是我当前的验证:
<script type="text/javascript">
function subForm()
{
if(confirm("Are you sure you want to delete this?"))
document.forms["addorg"].submit();
else
return false;
}
</script>
这是我在另一边的脚本:
if (isset($_POST["del"]) && ($_POST['del'] !== '')) {
$del = mysql_real_escape_string(html2txt($_POST['del']));
$resfile = mysql_query('SELECT file_loc from organization WHERE org_id = '.$del);
$org_name = mysql_real_escape_string(html2txt($_POST['orgname']));
if (!$resfile)
header('Location: '.$admin.'?error=query');
while ($filerow = mysql_fetch_array($resfile)) {
$fileplace = $filerow['file_loc'];
unlink(".".$fileplace);
rmdir($org_name);
}
mysql_query("DELETE from organization where org_id='".$del."'");
header('Location: '.$admin);
}
目前没有删除我想要的记录。如何将“del”名称传递到其他页面?
【问题讨论】:
-
您的查询容易受到SQL injection的攻击。
-
显示更多的 HTML。你的
<button>在<form>里面吗? -
您可以恢复到提交输入并将事件附加到表单的提交。无需使用按钮。
-
我最初是这样做的,Yoa,但我有另一个按钮,我不知道如何制作一个脚本来检测这两个按钮之间的差异。
标签: php javascript html