exec("CREATE TABLE IF NOT EXISTS `clients` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(150) NOT NULL, `phone` varchar(20) DEFAULT '', `email` varchar(150) DEFAULT '', `address` text DEFAULT NULL, `notes` text DEFAULT NULL, `is_blocked` tinyint(1) DEFAULT 0, `created_at` timestamp NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4"); } catch(Exception $e) {} // Block client if (isset($_GET['block'])) { $id = (int)$_GET['block']; try { $pdo->prepare("UPDATE clients SET is_blocked=1 WHERE id=?")->execute([$id]); $msg = "
Client has been blocked.
"; } catch(Exception $e) {} } // Unblock client if (isset($_GET['unblock'])) { $id = (int)$_GET['unblock']; try { $pdo->prepare("UPDATE clients SET is_blocked=0 WHERE id=?")->execute([$id]); $msg = "
Client has been unblocked.
"; } catch(Exception $e) {} } // Delete client if (isset($_GET['delete'])) { $id = (int)$_GET['delete']; try { $pdo->prepare("DELETE FROM clients WHERE id=?")->execute([$id]); $msg = "
Client deleted successfully.
"; } catch(Exception $e) { $msg = "
Error deleting client.
"; } } // Add client if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['action']) && $_POST['action'] == 'add') { try { $stmt = $pdo->prepare("INSERT INTO clients (name, phone, email, address, notes) VALUES (?,?,?,?,?)"); $stmt->execute([$_POST['name'], $_POST['phone'], $_POST['email'], $_POST['address'], $_POST['notes']]); $msg = "
Client added successfully!
"; } catch(Exception $e) { $msg = "
Error adding client.
"; } } // Edit client if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['action']) && $_POST['action'] == 'edit') { $id = (int)$_POST['id']; try { $pdo->prepare("UPDATE clients SET name=?, phone=?, email=?, address=?, notes=? WHERE id=?") ->execute([$_POST['name'], $_POST['phone'], $_POST['email'], $_POST['address'], $_POST['notes'], $id]); $msg = "
Client updated successfully!
"; } catch(Exception $e) { $msg = "
Error updating client.
"; } } // Fetch all clients $clients = []; $total = 0; $blocked = 0; try { $stmt = $pdo->query("SELECT * FROM clients ORDER BY created_at DESC"); $clients = $stmt->fetchAll(); $total = count($clients); $blocked = count(array_filter($clients, fn($c) => $c['is_blocked'])); } catch(Exception $e) {} ?>

Client Management

Total Clients

Active Clients

Blocked Clients

# Client Name Phone Email Address Status Added Actions
No clients added yet.
...
—' ?> —' ?> —' ?> Blocked Active