I'm trying to use my PHP to take input from a form and write it to an XML file. It works fine for the unique fields, but there's one field that can be inputted 4 times.
When more than one is entered, only the last one is written to the XML file.
My PHP:
<?php
if(isset($_REQUEST['ok'])){
$xml = new DOMDocument("1.0","UTF-8");
$xml->load("../Players.xml");
$rootTag = $xml->getElementsByTagName("site")->item(0);
$entryTag = $xml->createElement("entry");
$nameTag = $xml->createElement("name",$_REQUEST['name']);
$countryTag = $xml->createElement("country",$_REQUEST['country']);
$memTag = $xml->createElement("mem",$_REQUEST['mem']);
$entryTag->appendChild($nameTag);
$entryTag->appendChild($countryTag);
$entryTag->appendChild($memTag);
$rootTag->appendChild($entryTag);
$xml->save("../Players.xml");
}
?>
Form:
<form action="index.php" method="post">
<input type="text" name="name"/>
<input type="text" name="country"/>
<input type="text" name="mem"/>
<input type="text" name="mem"/>
<input type="text" name="mem"/>
<input type="text" name="mem"/>
<input type="submit" name="ok"/>
</form>