Hi all, looks like a great site/forum here
I’ve got a php form on my site that i’ve configured to email me plus update a MySQL database with the details.
The issue I now have is that I need the form contents to be added to individual XML files.
I’ve got the form to make a file with the contents, but now have two hurdles to overcome:
- To add the current date to one of the elements
- To create an individual xml file each time the form is submitted (at present it just overwrites it)
Here’s the code i’m currently plugging into a professionally written form (quform):
$doc = new DOMDocument(‘1.0’, ‘utf-8’);
// we want a nice output
$doc->formatOutput = true;
$root = $doc->createElement(‘srs’);
$root = $doc->appendChild($root);
// Affiliate Code
$affcode = $doc->createElement(‘affiliate_code’);
$affcode = $root->appendChild($affcode);
$text = $doc->createTextNode(‘000000’);
$text = $affcode->appendChild($text);
// Batch ID
$batchid = $doc->createElement(‘batch_id’);
$batchid = $root->appendChild($batchid);
$text = $doc->createTextNode(‘mybatchid’);
$text = $batchid->appendChild($text);
$sr = $doc->createElement(“sr”);
$sr = $root->appendChild($sr);
$data = $doc->createElement(“data”);
$data = $sr->appendChild($data);
// Data ID
$dataid = $doc->createElement(‘id’);
$dataid = $data->appendChild($dataid);
$text = $doc->createTextNode(‘BQ00001’);
$text = $dataid->appendChild($text);
$datacat = $doc->createElement(“category”);
$datacat = $data->appendChild($datacat);
// Data Date
$datadate = $doc->createElement(‘date’);
$datadate = $data->appendChild($datadate);
$text = $doc->createTextNode(‘2014-01-12’);
$text = $datadate->appendChild($text);
$doc->save(“testoutput.xml”);
Thanks for any guidance… my knowledge is very basic indeed (almost non-existent).
Regards
Tim