4
Hello, I have a PHP me code where I use simplexml_load_file to read an xml on this page I need to send a form with submit, My problem is that by sending this form xml data is lost. And I would like to know how I can keep my xml and send the submit?
NOTE: I have tried using $_SESSION to store the file address but it didn’t work.
Test.php
<!doctype html>
<html lang="pt-br">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <title> Projeto GP </title>
  </head>
  <body>
  <pre>
    <?php 
        print_r($_POST); 
    ?>
    </pre>
    <?php
    
        #------------------------------------------------------------------------------------------
        $myfile2 = $_FILES['XML']['tmp_name'];
        $xml = simplexml_load_file($myfile2);
        $frutas_array = $xml 
        #Recebe o XML e le ele 
        #------------------------------------------------------------------------------------------
    ?>
    <div>
        <form id ="form4.2" action="<?= $_SERVER['PHP_SELF'] ?>" method="post">
        <?php 
            foreach($frutas_array as $key => $fruta):
            #recuperando dados do xml atraves de um foreach
            #------------------------------------------------------------------------------------------
        ?>
            <label>A fruta é <?= $fruta ?></label>
            <input type="hidden" value="<?= $fruta ?>" name="frutas[<?= $key ?>][nome]">
            <input type="" name="frutas[<?= $key ?>][cor]">
            <!--criação de inputs a cada item do foreach -->
        <?php 
        endforeach 
        #finalizando o foreach apos a criação do formulario
        #------------------------------------------------------------------------------------------
        ?>
        <input type="submit" name="">
        <!--submit com direção para esta propria pagina -->
        </form>
    </div>    
</body>
</html>
						
can’t instead the file path, read the file in php and save what matters in Session? can even parse the xml for a class
– Ricardo Pontual