duandian8251 2017-03-13 08:35
浏览 23
已采纳

删除语句不会出错但不起作用

I have this delete statement that is meant to delete a row of data in a mysql table depending on the email that the users enters into the text field.

The query seems to go through with no errors but the data remains. I have a INSERT query with the same table and that is working perfectly.

My code:

<?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>
  • 写回答

1条回答 默认 最新

  • dsfdgdsfd23212 2017-03-13 08:42
    关注
        <?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
        }
        ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)