prepare("INSERT INTO products (name, sku, category, price, stock) VALUES (?, ?, ?, ?, ?)"); $stmt->execute([$name, $sku, $category, $price, $stock]); // Redirect to product list on success header('Location: products.php?success=Product+added'); exit; } catch (PDOException $e) { // Handle error, e.g., duplicate SKU // For now, we'll just redirect with a generic error error_log($e->getMessage()); header('Location: product_add.php?error=Could+not+add+product'); exit; } }