Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Creating XML file from HTML form

$
0
0

This might be confusing so I am going to do my best at describing this.

 

I have a simple HTML form that I am trying to create an XML file from the data. Here is the link to the form.

 

http://www.mesquiteweather.net/wxmesqLSR-report.php

 

This is the php script I am using to create the XML which works if you don't redirect after the form has been submitted but, I need it to redirect so you can view the data. It populates with the data if you don't redirect. Problem is it doesn't show on the page it needs to be viewed on. Also once  data has been entered it deletes the previous data.

<?php
if (isset($_POST['lsr-submit']))
    {
        header('Location: wxmesqLSR.php');
    }
header('Content-type: text/xml');//Tell the browser it's an XML document
ob_start();
echo '<?xml version="1.0"?'.'>'."\n";//We have to break up the XML closing tag because [?]> is the closing tag for PHP
echo "<entry>
 <reports>
   <fname>{$_POST['firstname']}</fname>
   <lname>{$_POST['lastname']}</lname>
   <location>{$_POST['location']}</location>
   <report>{$_POST['report']}</report>
   <description>{$_POST['desc']}</description>
 </reports>
</entry>";
?>

What would be a good way to achieve what I am trying to do? I just need people to be able to enter info in the form and store it in a XML file and retain it for X amount of time. If I manually create a XML file the data displays fine so I know it is reading the XML file.

 

-Thanks


Viewing all articles
Browse latest Browse all 13200

Trending Articles