PHP删除表单不删除没有错误

新123

该表单应该通过输入客户 ID 从客户表中删除客户行,但它没有做它应该做的,我不知道为什么!当我执行 PHP 文件时,我没有收到任何错误。

我知道它应该可以工作,因为我使用相同的代码从员工表中删除信息并且工作正常。

删除客户表单

<!DOCTYPE html>
     <head>
    <?php include 'project_header.php'; ?>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  </head>

    <body>
    <form action="customer_delete.php" method="post">
        <h2> Delete a Customer</h2>
        <p>Please Enter Customer Information:</p>
            Customer ID: <input type="text" ID="Customer_ID"/><br>    
        <input type="submit" value= "Delete"/><input type="reset"/>
        </form>
    </body>

 <?php include 'project_footer.php'; ?>
   </html>

删除客户 PHP

<!DOCTYPE html>
<html>
<?php include 'project_header.php'; ?>
<body>
<?php
include_once 'db.php';
include_once 'display.php';

#form data
$Customer_ID=$_POST['Customer_ID'];

$sql = "delete from CUSTOMERS where Customer_ID = :Customer_ID;";
$stmt = $conn->prepare($sql);

# data stored in an associative array
$data = array( 'Customer_ID' => $Customer_ID);

if($stmt->execute($data)){
                $rows_affected = $stmt->rowCount();
                echo "<h2>".$rows_affected." row deleted sucessfully!</h2>";
                display("select Customer_ID as Customer ID FROM CUSTOMERS;");
}
else
{
        echo "\nPDOStatement::errorInfo():\n";
        print_r($stmt->errorInfo());
}
$stmt = null;
$conn = null;
?>
</body>
<?php include 'project_footer.php'; ?>
</html>

丹德莫

name您的文本框中似乎没有属性。这就是 PHP 获取POST信息的方式,因此如果没有设置,您将无法访问用户输入的内容。只需将属性从 更改IDname(或仅在需要时添加name属性id),就可以解决问题。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Laravel 和 Vuejs axios 删除没有错误但不删除

MongoDB不删除行,使用C#驱动程序没有错误

MySQL删除没有错误的地方

查找和删除子目录没有错误?

cx_oracle-删除无效。没有错误或异常

当我尝试使用Hibernate删除实体时,没有错误消息但没有删除

PHPMailer表单没有错误或发送

表单验证jQuery没有错误

PHP如何提交表单,如果没有错误。没有JavaScript

PHP表单到数据库-没有错误,但没有结果

Angular Forms Custom Validator null Return不删除表单错误

集成设置代码会导致链接器错误;删除代码,没有错误

主函数上的已删除通道错误,但在goroutine中已删除的progrenn则没有错误

文件不删除表单文件夹php

使用SQL从WordPress帖子中删除HTML失败而没有错误

无法在Windows 10中删除文件夹-没有错误消息

Angular中的http删除功能出现问题,没有错误

AS3-removeChild认为它正在运行,但是没有删除任何东西(没有错误)

PHP不删除空格并显示错误的字符长度

Symfony中的无效表单没有错误

表单不更新值,验证失败但没有错误

从表单中删除 Panel 对象而不删除其所有子对象

JavaScript remove带有错误值的删除键

装饰器将功能名称存储到文件中,如果没有错误则将其删除

上载表单文件,添加加载微调器,放置错误,完成后不删除

MVC 5 - 尝试使用 linq 删除一行时,没有错误并且该行未被删除。为什么?

php ajax插入显示空白响应但没有错误

PHP单页提交失败,没有错误

PHP stmt prepare失败,但是没有错误