'', 'rate' => 0.00 ]; if (isset($_GET['id'])) { // ID param exists, edit an existing tax $page = 'Edit'; if (isset($_POST['submit'])) { // Update the tax $categories_list = isset($_POST['categories']) ? implode(',', $_POST['categories']) : ''; $products_list = isset($_POST['products']) ? implode(',', $_POST['products']) : ''; $stmt = $pdo->prepare('UPDATE taxes SET country = ?, rate = ? WHERE id = ?'); $stmt->execute([ $_POST['country'], $_POST['rate'], $_GET['id'] ]); header('Location: index.php?page=taxes&success_msg=2'); exit; } if (isset($_POST['delete'])) { // Delete the tax $stmt = $pdo->prepare('DELETE FROM taxes WHERE id = ?'); $stmt->execute([ $_GET['id'] ]); header('Location: index.php?page=taxes&success_msg=3'); exit; } // Get the tax from the database $stmt = $pdo->prepare('SELECT * FROM taxes WHERE id = ?'); $stmt->execute([ $_GET['id'] ]); $tax = $stmt->fetch(PDO::FETCH_ASSOC); } else { // Create a new tax $page = 'Create'; if (isset($_POST['submit'])) { $stmt = $pdo->prepare('INSERT INTO taxes (country,rate) VALUES (?,?)'); $stmt->execute([ $_POST['country'], $_POST['rate'] ]); header('Location: index.php?page=taxes&success_msg=1'); exit; } } ?>

Tax

Cancel