我已经使用了此html代码
<form method="POST">
<input type="button" id="delete" name="delete" value="delete">
</form>
以及以下用于从表中删除数据的代码:
$usr = $_SESSION["user"];
if(empty($_POST['delete'])) {
$query="delete from roombook where Email='$usr'";
$res= mysqli_query($con,$query);
if($res->num_rows>0) {
echo"<script>alert('Deleted');</script>";
}
}else {
echo"<script>alert('delete failed');</script>";
}
} else {
echo"<script>alert('not found');</script>";
}
但是它总是向我显示else语句的输出,即:删除失败
答案 0 :(得分:0)
您的表格
<input type="button" id="delete" name="delete" value="delete">
应为以下代码:
<input type="submit" id="delete" name="delete" value="delete">