'; echo '

Zugriff verweigert

'; echo '

Du hast keine Berechtigung, Angebote hinzuzufügen.

'; echo '
'; include 'footer.php'; exit; } $db = db_get_connection(); $message = ''; $messageType = ''; if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'add_offer') { $productID = (int)$_POST['product_id']; $shopID = (int)$_POST['shop_id']; $price = (float)$_POST['price']; $shippingCost = isset($_POST['shipping_cost']) && $_POST['shipping_cost'] !== '' ? (float)$_POST['shipping_cost'] : 0.00; $inStock = isset($_POST['in_stock']) ? 1 : 0; $offerURL = trim($_POST['offer_url']); if ($productID > 0 && $shopID > 0 && $price >= 0) { $stmt = $db->prepare("INSERT INTO offers (productID, shopID, price, shippingCost, inStock, offerURL) VALUES (?, ?, ?, ?, ?, ?)"); if ($stmt->execute([$productID, $shopID, $price, $shippingCost, $inStock, $offerURL])) { $message = 'Angebot erfolgreich hinzugefügt!'; $messageType = 'success'; } else { $message = 'Fehler beim Hinzufügen des Angebots.'; $messageType = 'error'; } } else { $message = 'Bitte alle Pflichtfelder korrekt ausfüllen.'; $messageType = 'error'; } } // Get all products for dropdown $productsStmt = $db->query("SELECT productID, model FROM products ORDER BY model ASC"); $products = $productsStmt->fetchAll(PDO::FETCH_ASSOC); // Get all shops for dropdown $shopsStmt = $db->query("SELECT shopID, name FROM shops ORDER BY name ASC"); $shops = $shopsStmt->fetchAll(PDO::FETCH_ASSOC); include 'header.php'; ?>

Angebot hinzufügen