I'm having hard time to do a php post to a XML data here is my form:
<form action="../xml/data.php" method"post">
<p>Name</p>
<input name='name' required><br>
<p>ID</p>
<input name"id" required>
<input type='submit' value ="submit" name="submit">
</form>
here is my PHP code:
<?php
$s_id=$_POST['id'];
$s_name=$_POST['name'];
$xml = new DOMDocument("1.0");
$student = $xml -> createElement("student");
$xml -> appendChild($student);
$id_value = $xml ->createTextNode("$s_id");
$id -> appendChild($id_value);
$name = $xml -> createElement("name");
$student -> appendChild($name);
$name_value=$xml->createTextNode("$s_name");
$name->appendChild($name_value);
$xml ->formatOutput = true;
$xml -> save("mydata.xml");
?>
But it doesn't make the mydata.xml file and not working :s not sure what i'm doing wrong here