gpt4 book ai didi

php - 删除语句没有给出错误但也不起作用

转载 作者:行者123 更新时间:2023-11-27 23:16:40 24 4
gpt4 key购买 nike

我有这个删除语句,旨在根据用户在文本字段中输入的电子邮件删除 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: user@mail.co.za">
<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 - 删除语句没有给出错误但也不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42759322/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com