prepare('DELETE FROM vendors WHERE id = ?'); $stmt->execute([$vendor_id]); header("Location: vendors.php?success=2"); exit; } catch (PDOException $e) { $errorMessage = "Error: Could not delete the vendor. " . $e->getMessage(); } } } // Handle form submission for adding a new vendor if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_vendor'])) { $name = trim($_POST['name'] ?? ''); $service_type = trim($_POST['service_type'] ?? ''); $contact_email = filter_input(INPUT_POST, 'contact_email', FILTER_VALIDATE_EMAIL); $contact_phone = trim($_POST['contact_phone'] ?? ''); $rating = filter_input(INPUT_POST, 'rating', FILTER_VALIDATE_FLOAT); if (empty($name) || empty($service_type) || !$contact_email) { $errorMessage = "Error: Vendor name, service type, and a valid email are required."; } else { try { $pdo = db(); $stmt = $pdo->prepare('INSERT INTO vendors (name, service_type, contact_email, contact_phone, rating) VALUES (?, ?, ?, ?, ?)'); $stmt->execute([$name, $service_type, $contact_email, $contact_phone, $rating]); header("Location: vendors.php?success=1"); exit; } catch (PDOException $e) { $errorMessage = "Error: Could not add the vendor. " . $e->getMessage(); } } } // Handle success messages if (isset($_GET['success'])) { if ($_GET['success'] == 1) $successMessage = "Vendor added successfully!"; if ($_GET['success'] == 2) $successMessage = "Vendor deleted successfully!"; if ($_GET['success'] == 3) $successMessage = "Vendor updated successfully!"; } // Fetch vendors from the database $vendors = []; try { $pdo = db(); $stmt = $pdo->query('SELECT * FROM vendors ORDER BY name'); $vendors = $stmt->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { $errorMessage = "Error: Could not connect to the database."; } ?> Vendors - The Best Events

Manage Vendors

No vendors found. Get started by adding one!
Service:

Contact: |

Rating: / 5
Edit