Inserting Query String Variables in XML using PHP/curl

Golderss

New Member
I'm trying to send some information to our CRM from a form on our site and am getting stuck on inserting the variables into the XML. Here is a simplified version of my code. Notice where I'm trying to insert the $email variable within the XML variable...which is not working. \[code\]<?php$email = $_GET["email"];$xml = '<xmlrequest><details> <emailaddress>$email</emailaddress> <mailinglist>8</mailinglist> <format>html</format> <confirmed>no</confirmed></details></xmlrequest>'; $ch = curl_init('http://mysite.com/xml.php'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); $result = @curl_exec($ch); if ($result === false) {echo "Error performing request"; } else {$xml_doc = simplexml_load_string($result);header( "Location: http://mysite.com/confirmation?email=$email" ) ;//echo 'Status is ', $xml_doc -> status, '<br/>'; if ($xml_doc -> status == 'SUCCESS') { echo 'Data is ', $xml_doc -> data, '<br/>';} else { echo 'Error is ', $xml_doc -> errormessage, '<br/>';}}?>\[/code\]If I just type in an email address value for the API works fine. However, I'm clueless on how to pull this in dynamically from a PHP variable. Any help is greatly appreciated!
 
Back
Top