'danger', 'text' => 'Invalid input. Please fill all fields correctly.']; header('Location: index.php'); exit; } $pdo = db(); if ($pdo) { try { $stmt = $pdo->prepare( "INSERT INTO leads (lead_name, status, category, contact_email, owner) VALUES (?, ?, ?, ?, ?)" ); $stmt->execute([$lead_name, $status, $category, $contact_email, $owner]); $_SESSION['message'] = ['type' => 'success', 'text' => 'Lead added successfully!']; } catch (PDOException $e) { error_log('Add Lead Error: ' . $e->getMessage()); $_SESSION['message'] = ['type' => 'danger', 'text' => 'A database error occurred.']; } } else { $_SESSION['message'] = ['type' => 'danger', 'text' => 'Could not connect to the database.']; } } header('Location: index.php'); exit; ?>