prepare("UPDATE products SET name = ?, type = ?, stock_quantity = ?, purchase_price = ?, sale_price = ?, low_stock_threshold = ? WHERE id = ?"); $stmt->execute([$name, $type, $stock_quantity, $purchase_price, $sale_price, $low_stock_threshold, $product_id]); $_SESSION['notification'] = "Ürün başarıyla güncellendi."; header('Location: products.php'); exit(); } catch (PDOException $e) { $_SESSION['error'] = "Veritabanı hatası: " . $e->getMessage(); } } else { $_SESSION['error'] = "Lütfen tüm alanları doğru bir şekilde doldurun."; } // Hata durumunda aynı sayfada kal, form tekrar dolsun header("Location: edit-product.php?id=" . $product_id); exit(); } // Sayfa ilk yüklendiğinde (GET request) try { $stmt = $pdo->prepare("SELECT * FROM products WHERE id = ?"); $stmt->execute([$product_id]); $product = $stmt->fetch(PDO::FETCH_ASSOC); if (!$product) { $_SESSION['error'] = "Ürün bulunamadı."; header('Location: products.php'); exit(); } } catch (PDOException $e) { $_SESSION['error'] = "Veritabanı hatası: " . $e->getMessage(); header('Location: products.php'); exit(); } require_once 'partials/header.php'; ?>

Ürünü Düzenle

İptal