trim($_POST['name'] ?? ''), 'email' => trim($_POST['email'] ?? ''), 'phone' => trim($_POST['phone'] ?? ''), 'caseTypeId' => (int)($_POST['caseTypeId'] ?? 0), 'message' => trim($_POST['message'] ?? ''), 'sourceUrl' => $_SERVER['HTTP_REFERER'] ?? '', ]; $ch = curl_init($apiBaseUrl . '/api/leads'); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ 'Content-Type: application/json', 'X-Api-Key: ' . $apiKey, ], CURLOPT_POSTFIELDS => json_encode($payload, JSON_THROW_ON_ERROR), ]); $responseBody = curl_exec($ch); $statusCode = (int)curl_getinfo($ch, CURLINFO_RESPONSE_CODE); curl_close($ch); if ($statusCode >= 200 && $statusCode < 300) { $resultMessage = 'Lead submitted successfully.'; } else { $resultMessage = 'Submission failed: ' . $responseBody; } } ?> PHP Affiliate Form Starter

PHP Affiliate Form