When writing data there are two primary operations. Create a record and Update a record. bxp uses a simple system, IF the Id is set, it is an update. If the ID is not set, then a new record will be created.
The Id field is intCDA_X_Id. The function is called the formlogging.
<syntaxhighlight lang="php">
<?php
//=========================================================
== Read some data ==
So to read from a form, we use the material as per 7.4.3 Website – Data Query
This example looks up where the Id of the CDA record is 1 in form 56, retrieving fields strCDA_56_field_1_5 and strCDA_56_field_3_5.
<syntaxhighlight lang="php">
<?php
//=========================================================
//Data Setup
//=========================================================
//set POST variables
extract($_POST);
$url = 'https://ww3.allnone.ie/client/client_demo/cti/userCTI_GenericEntry.asp';
$fields = array(
'user_id' => urlencode('testing'),
'user_key' => urlencode('testing'),
'system' => urlencode('datasearch'),
'campaignid' => urlencode('56'),
'searchfield' => urlencode('intCDA_56_Id'),
'value' => urlencode('1'),
'responsefields' => urlencode('strCDA_56_field_1_5,strCDA_56_field_3_5')
);
//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string,'&');
//=========================================================
//Process Data
//=========================================================
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url );
curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string );
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1 );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
//=========================================================
//Handling xml data
//=========================================================
if (strpos($result,'xml version="')) {
$data = new SimpleXMLElement($result);
echo $data>getName() . "<br />";
foreach($data>children() as $child) {
echo $child>getName() . ": " . $child . "<br />";
}
}
else {
echo $result;
}
?>
</syntaxhighlight>