在我的源代码当我按下删除按钮时,内部的代码没有执行。任何人都可以帮助我,
<body>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<?php
$dbc=mysqli_connect("localhost","root","","elvis_store") or die("Error Connecting to Mysql Database");
if(isset($_POST['submit'])){
echo "Hello";
foreach($_POST['todelete'] as $delete_id){
$query="DELETE FROM email_list WHERE id=$delete_id";
mysqli_query($dbc,$query) or die("Error Querying Database");
}
echo "Customer(s) Removed";
}
$query="SELECT * FROM email_list";
$result=mysqli_query($dbc,$query)or die("Query Syntaxt is Incorrect");
while($row=mysqli_fetch_array($result)){
echo '<input type="checkbox" value="' . $row['id'] . '" name="todelete[]" />';
echo $row['first_name']." ".$row['last_name']." ".$row['email'];
echo "<br/>";
}
mysqli_close($dbc);
?>
<input type="submit" name"submit" value="Remove"/>
</form>
</body>
答案 0 :(得分:3)
也许这个
name"submit"
是问题吗?
答案 1 :(得分:2)
尝试:
if(isset($_POST) && !empty($_POST)) {
}
答案 2 :(得分:0)
首先,html不正确 - &gt;名称“提交”必须是name =“submit”
其次,我建议你首先检查是否设置了$ _POST ['submit'],如果是,那么php会显示表单。