title: Creating XML file from HTML form
body: <p>Ok so I got it working, now the only problem is when a new submission is added it overwrites the previous entry. I need it to add the newest submission to the XML file and not over ride it and store it for X amount of time. </p>
  
  <p>Here is the working php script that creates the xml file and takes the data from the HTML form and puts it in the XML file. </p>
  
  <pre><code>&lt;?php
  
  if (isset($_POST['lsr-submit']))
      {
          header('Location: http://www.mesquiteweather.net/wxmesqLSR.php');
      }
  
  $str = '&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;entrys&gt;&lt;/entrys&gt;';
  $xml = simplexml_load_string($str);
  
  $fname = $_POST['firstname'];
  $lname = $_POST['lastname'];
  $location = $_POST['location'];
  $report = $_POST['report'];
  $description = $_POST['desc'];
  
  $fname = htmlentities($fname, ENT_COMPAT, 'UTF-8', false);
  $lname = htmlentities($lname, ENT_COMPAT, 'UTF-8', false);
  $location = htmlentities($location, ENT_COMPAT, 'UTF-8', false);
  $report = htmlentities($report, ENT_COMPAT, 'UTF-8', false);
  $description = htmlentities($description, ENT_COMPAT, 'UTF-8', false);
  
  $xml-&gt;reports = "";
  $xml-&gt;reports-&gt;addChild('fname', $fname);
  $xml-&gt;reports-&gt;addChild('lname', $lname);
  $xml-&gt;reports-&gt;addChild('location', $location);
  $xml-&gt;reports-&gt;addChild('report', $report);
  $xml-&gt;reports-&gt;addChild('description', $description);
  
  $doc = new DOMDocument('1.0');
  $doc-&gt;formatOutput = true;
  $doc-&gt;preserveWhiteSpace = true;
  $doc-&gt;loadXML($xml-&gt;asXML(), LIBXML_NOBLANKS);
  $doc-&gt;save('test2.xml');
  
  ?&gt;
  </code></pre>
  
  <p>Here is the xml file it creates. </p>
  
  <p><a href="http://www.mesquiteweather.net/xml/test2.xml" rel="nofollow">XML FILE</a></p>
  
  <p>Here is the form to submit to the XML file. Submit a test submission and it takes you to the page to display but you'll notice it will overwrite the last one instead of adding to the XML file. </p>
  
  <p><a href="http://www.mesquiteweather.net/wxmesqLSR-report.php" rel="nofollow">HTML FORM</a></p>