prepare("UPDATE products SET name = ?, description = ?, price = ?, barcode = ? WHERE id = ?"); $stmt->execute([$name, $description, $price, $barcode, $id]); $_SESSION['success_message'] = "Product updated successfully!"; } catch (PDOException $e) { error_log("Product update failed: " . $e->getMessage()); $_SESSION['error_message'] = "Failed to update product. Please try again."; } header('Location: /dashboard.php?page=admin_products'); exit;