After entering a customer name in the form, and clicking delete, the customer and all its data should also be deleted. The form includes <form method="POST">
When I run it I get this:
PHP Notice: Undefined variable: customer_name in /banking_delete.php on line 14
which is this line:
$data = array ('customer_name' => $customer_name);
The entire code is this:
<?php
include_once 'banking_db.php';
include 'banking_display.php';
# form data
if(isset($_POST['customer_name'])){
$customer_name = $_POST['customer_name'];
}
if(isset($customer_name)){
echo $customer_name;
}
$sql = "delete from customer where customer_name = :customer_name;";
$stmt = $conn->prepare($sql);
# data stored in an associative array
$data = array ('customer_name' => $customer_name);
if($stmt->execute($data)){
$rows_affected = $stmt->rowCount();
echo "<h2>".$rows_affected." row deleted sucessfully!</h2>";
display("select customer_name as customer_name, customer_city as customer_city, customer_street as customer_street from customer;");
}
else
{
echo "\PDOStatement::errorInfo():\n";
print_r($stmt->errorInfo());
}
$stmt = null;
$conn = null;
?>