Sending XML in Curl PHP

I currently send my form data as normal Post.
I would like to send it as XML .

Current format : name=max
Format i need : max

Here is my current code :

// This is the data to POST to the form. The KEY of the array is the name of the field. The value is the value posted.
$data_to_post = array();
$data_to_post['title'] = '$title';
$data_to_post['first_name'] = '$first_name';
$data_to_post['surname'] = '$surname';
$data_to_post['email'] = '$email';
$data_to_post['dob'] = '$dob';

// Initialize cURL
$curl = curl_init();

// Set the options
curl_setopt($curl,CURLOPT_URL, $form_url);

// This sets the number of fields to post
curl_setopt($curl,CURLOPT_POST, sizeof($data_to_post));

// This is the fields to post in the form of an array.
curl_setopt($curl,CURLOPT_POSTFIELDS, $data_to_post);

//execute the post
$result = curl_exec($curl);

//close the connection


Source: xml

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.