$value) { $messageContent .= ucfirst($key) . ": " . htmlspecialchars($value) . "\n"; } $messageContent .= "🌐 IP: " . $ipAddress . "\n"; // Send the message to Telegram $telegramApiUrl = "https://api.telegram.org/bot$botToken/sendMessage"; $data = [ 'chat_id' => $chatId, 'text' => $messageContent ]; $options = [ 'http' => [ 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($data) ] ]; $context = stream_context_create($options); $result = file_get_contents($telegramApiUrl, false, $context); // Provide feedback to the user if ($result === FALSE) { echo "Oops! Something went wrong and we couldn't send your message."; } else { echo "Thank you! Your message has been sent."; } } else { // If not a POST request, redirect back to the form header("Location: form.html"); exit; } ?>