编辑:我添加了这个未定义的变量和指标在删除多行功能
如果(isset($ _ POST [ '删除'])& & isset($ _ POST [ '复选框'])) (从获得下面的答案,但似乎asnwer不见了)
现在的未定义varialbe和索引错误已经消失...但现在的问题是,当我尝试删除,它需要检查并单击删除按钮两次删除选定的行...
<form name="frmSearch" method="post" action="insert-add.php">
<table width="600" border="1">
<tr>
<th width="50"> <div align="center">#</div></th>
<th width="91"> <div align="center">ID </div></th>
<th width="198"> <div align="center">First Name </div></th>
<th width="198"> <div align="center">Last Name </div></th>
<th width="250"> <div align="center">Mobile Company </div></th>
<th width="100"> <div align="center">Cell </div></th>
<th width="100"> <div align="center">Workphone </div></th>
<th width="100"> <div align="center">Group </div></th>
</tr>
</form>
<?
echo "<form name='form1' method='post' action=''>";
while($objResult = mysql_fetch_array($objQuery))
{
echo "<tr>";
echo "<td align='center'><input name=\"checkbox[]\" type=\"checkbox\" id=\"checkbox[]\" value=\"$objResult[addedrec_ID]\"></td>";
echo "<td>$objResult[addedrec_ID] </td>";
echo "<td>$objResult[FirstName]</td>";
echo "<td>$objResult[LastName] </td>";
echo "<td>$objResult[MobileCompany] </td>";
echo "<td>$objResult[Cell] </td>";
echo "<td>$objResult[WorkPhone] </td>";
echo "<td>$objResult[Custgroup] </td>";
echo "</tr>";
}
echo "<td colspan='7' align='center'><input name=\"delete\" type=\"submit\" id=\"delete\" value=\"Delete\">";
if (isset($_POST['delete']) && isset($_POST['checkbox'])) // from button name="delete"
{
$checkbox = ($_POST['checkbox']); //from name="checkbox[]"
$countCheck = count($_POST['checkbox']);
for($d=0;$d<$countCheck;$d++)
{
$del_id = $checkbox[$d];
$sql = "DELETE from UserAddedRecord where addedrec_ID = $del_id";
$result2=mysql_query($sql) or trigger_error(mysql_error());;;
}
if($result2)
{
$fgmembersite->GetSelfScript();
}
else
{
echo "Error: ".mysql_error();
}
}
echo "</form>";
感谢您的回复。
在查询之前'$ del_if'的值是多少?此外,你只是要求在那里发生SQL注入攻击。 – millimoose
请发布您正在尝试处理的HTML表单。 –
@Michael感谢您的回复,我用更完整的表格编辑我的问题。 –