Forum Moderators: coopster
I have created this code to get data from a html form into php and then generate an xml file. I am having a problem looping....I need it to loop so that if there is more than one caption that has been submitted then a new line of xml will start with the corresponding data. Each loop i have tried has given me an error saying the header has already been sent.
Here is my code......thanks in advance
<?php
if(isset($_POST['create_xml'])){
$picT = $_POST['picT'];
$photoT = $_POST['photoT'];
$captionT = $_POST['captionT'];
$xmltext = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<gallery></gallery>";
$xmlobj = simplexml_load_string($xmltext);
$nameCapsA = $xmlobj->addChild("$picT");
$nameCapsA->addAttribute("name", "$photoT");
$nameCapsA->addAttribute("caption", "$captionT");
// set output filename
$filename= "test1.xml";
print header("Content-type: text/plain") . $xmlobj->asXML();
}
?>