<html>
<head/>
<body>
<?php
if ($_POST[user]<>'') {
	$data = simplexml_load_file('xml/users.xml');	
	$finddata="//users/$_POST[user]/*";
	$dresult=$data->xpath($finddata);
	if (count($dresult)==0) {
		$newUser = $data->addChild("$_POST[user]");
		$newUser->addChild("group","$_POST[group]");
		$newUser->addChild("playing","$_POST[playing]");
		}
	else {
		$data->$_POST[user]->playing = "$_POST[playing]";
		$data->$_POST[user]->group = "$_POST[group]";
		}
	$dom = new DOMDocument('1.0');
	$dom->preserveWhiteSpace = false;
	$dom->formatOutput = true;
	$dom->loadXML($data->asXML());

	//Save XML to file - remove this and following line if save not desired
	$dom->save('xml/users.xml');
	echo "User added/amended<br/><br/>";	
	}
?>
<form action='useradmin.php' method=post>
User:<input type=text name=user></input>
Group:<input type=text name=group></input>
Playing:<input type=text name=playing></input>
<input type=submit>
</form>