I am trying to modify the code of an html page after filling out a form with the new data that has to be displayed. When I save the form I am directed to a php file to save the changes in the database and from there access the .html file to modify it:
<?php
// Guardar cambios en base de datos OK
//Modificar html
$error="";
$file = "cIndex.html"; // el fichero se encuentra en la misma ruta
$DOM = new DOMDocument();
if( file_exists("cIndex.html") == true )
$DOM->loadHTMLFile($file); //entra aqui, fichero encontrado
else
$error = "No existe";
$DOM->loadHTMLFile($file);
$cName = $DOM->getElementsById('cName'); //al añadir esta línea me da error 500 Internal Server Error. Si la quito $DOM lo devuelve vacío.
$DOM->saveHTML();
$respuesta = array (
"error" => $error, //""
"file" => $file, // "cIndex.html"
"DOM" => $DOM //lo devuelve vacío {}
);
echo json_encode($respuesta);