I'm trying to make a script to read an XML file, insert it in a form and edit and update the values using php.
The form loads the present data, but does not update them.
Can anyone tell me a tip? Thanks Maurizio
file XML
<?xml version="1.0" encoding="UTF-8"?>
<myxml>
<data name="en_title"><![CDATA[mytitle]]></data>
<data name="en_scene_title"><![CDATA[ES000021903]]></data>
</myxml>
file edit PHP
<?php
$form_fields = null;
$data = simplexml_load_file('messages_en.xml');
foreach($data->data as $field)
{
$form_fields .= '<div>';
$form_fields .= '<label>' .$field['name'] . ' </label>';
$form_fields .= '<input type="text" id="' .$field['name'] . '"placeholder="'.htmlentities($field).'" name="'.$field. '" />';
$form_fields .= '</div>';
}
?>
<!DOCTYPE html>
<html>
<head>
<style>
form { font-size: 16px; }
form div { margin: .3em; }
legend { font-weight: bold; font-size: 20px; }
label { display:inline-block; width: 140px; }
</style>
</head>
<body>
<form method="POST" action="process.php">
<legend> Enter Contact Information</legend>
<?php echo $form_fields; ?>
<input type="submit" name="submit" value="Upload" class="btn" />
</form>
</body>
</html>
code file process.php
<?php
$xml = file_get_contents('messages_en.xml');
$sxml = simplexml_load_string($xml);
if(isset($sxml->item[$_POST['name']])) {
$node->data = $_POST['name'];
}
file_put_contents('messages_en.xml', $sxml->asXML());
?>
$node?$sxmlgoing to contain an array of the twodataelements?