Log in

View Full Version : simple xml update from php form



chriskq
10-29-2008, 02:42 AM
Hey all,

basically i have a little client list on a wiki that reads data from an xml file called db_staffList.xml eg:



<staff>
<name><![CDATA[Adam Smith]]></name>
<mobile>0420 111 222</mobile>
<extension>4444</extension>
<title>Executive Pimper</title>
<email>adam.smith@company.com.au</email>
</staff>


and i am using xmlParser.php to do this and to display the results on a wiki page.

That's all working a-ok, but i would like a non coding person to be able to update the db_staffList.xml with new items.

to do this i would like to make a simple php form page that posts a new staff member into the xml file. All thats needed is 5 inputs and a submit btn eg:


<form name="input" action="insert.php" method="post">
<p>Insert new client:</p>
<input type="text" name="name" />
<input type="text" name="mobile" />
<input type="text" name="extension" />
<input type="text" name="title" />
<input type="text" name="email" />
<input type="submit" value="send" />
</form>


can someone guide/help me in doing this – im still very new to php. Validation isnt really required for the time being – that can be phase 3.

maneetpuri
11-05-2008, 11:49 AM
Hi,

You can use to the file() function of PHP, which is for handling files. You can use this function to amend new data to the XML file.

One thing that you will have to do will be i.e. the XML file should be given 777 permission so that it can be written by the PHP script.

Hope this helps!

Cheers,

~Maneet
LeXolution IT Services
Web Design Company (http://www.lexolutionit.com)