我有一个delete语句,它是根据用户在文本字段中输入的电子邮件删除mysql表中的一行数据。
查询似乎没有出错,但数据仍然存在。我有一个带有相同表的INSERT查询,它工作得很好。
我的代码:
<?php
require ("database.php");
if($_POST['action'])
{
$email =$_GET['Email'];
// sending query
mysql_query("DELETE FROM List WHERE Email = '$email'")
or die(mysql_error());
header("Location: admin.php");
}
?>
<center><form action="" method="post">
<h1> Delete Email </h1>
<br>
Email:<br><input type="text" name="Email" required placeholder="@alpinemotors.co.za"
pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$" title="Must be a valid email address, eg: [email protected]">
<br/>
<br><h2><input type="submit" name="action" value="Delete Email">
<br></h2>
<h3>
<a href="admin.php"> Main Menu </a>
</h3>
</form>
</center>
最佳答案
<?php
require ("database.php");
if(isset($_POST['action']))
{
$email =$_POST['Email'];
// sending query
mysql_query("DELETE FROM List WHERE Email = '".$email."'")
or die(mysql_error());
header("Location: admin.php");
}
else
{
//form did not submit
}
?>
关于php - Delete语句不给出错误,但也不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42759322/