I would not quote $cid
if it is a number.
We quote STRING values.
"DELETE FROM customers WHERE customer_id = $customer_id"
$_GET['cid'] error you did find yourself
I have changed error reportin to display error number like: (1)
Remember now, that once the script has deleted record once
it will report error number (1) every time after.
So, in order to test your script is working alright
you need to INSERT $customer_id again, before run script
This is what I think it should be:
<?php
// This page deletes the customer account.
$problem = FALSE; // Assume no problem.
// Start the PHP page.
$page_title = 'Delete Account';
include ('./includes/header.php');
if (isset($_GET['cid'])) { // Make sure there's a customer ID.
$customer_id = $_GET['cid'];
require_once ('/mysqli_connect.php'); // Connect to the database.
$query = "DELETE FROM customers WHERE customer_id=$customer_id";
$result = mysqli_query ($dbc, $query) or die("Error: ".mysqli_error($dbc));
if (mysqli_affected_rows($dbc) == 1) { // Good to go
echo '<div align="center"><font size="+1">The selected customer account has been deleted</font></div>';
} else { // No record returned from the database.
$problem = 1;
}
mysqli_close($dbc); // Close the database connection.
} else { // No customer ID.
$problem = 2;
}
if ($problem) { // Show an error message.
$page_title = 'Error';
echo '<div align="center"><font size="+1">The account could not be deleted ('.$problem.')</font></div>';
}
// Complete the page.
include ('./includes/footer.php');
?>