0

I am using file_put_contents, ob_get_contents to generate a static html page from the entire php page. there is a HTML form on the PHP page which will be generated in the html as well.

the form has an ID of myForm.

what i need to do is to generate the HTML as it is but leave out the "myForm". basically I don't want the form in the newly created HTML page.

Here is what i use to generate the html page from my PHP page:

<?php 
if ((isset($_POST["music1"])) && (isset($_POST["music2"])))  
{ 

file_put_contents($options[$_POST['music1']].'+'.'and'.'+'.$options[$_POST['music2']].'.html', ob_get_contents());


}
// end buffering and displaying page
ob_end_flush();

?>

is there anyway to target the "myForm" ID while the html page is being created and opt it out?

EDIT: this question is not duplicated as far as i can see. I am not asking "how to use simple html dom parser"! that's why i specifically provided the code that I am using which is ob_get_clean. I am not sure if i am missing something?

EDIT:

This is what I have now and it doesn't work:

    <?php 
    if ((isset($_POST["music1"])) && (isset($_POST["music2"])))  
    { 

    $foo = '
    <style>
        #myForm {
          display: none;
        }
    </style>
</header>';
$finalHTML = str_replace('</header>', $foo, $currentHTML);file_put_contents($options[$_POST['music1']].'+'.'and'.'+'.$options[$_POST['music2']].'.html', ob_get_contents());


    }
    // end buffering and displaying page
    ob_end_flush();

    ?>

1 Answers1

0

Why don't you simply add a CSS?

<style>
    #myform {
      display: none;
    }
</style>

Edit: How about trying this hack:

$foo = '
    <style>
        #myForm {
          display: none;
        }
    </style>
</header>';
$finalHTML = str_replace('</header>', $foo, $currentHTML);

Edit:

in your case:

   <?php 
    if ((isset($_POST["music1"])) && (isset($_POST["music2"])))  
    { 

    $foo = '
    <style>
        #myForm {
          display: none;
        }
    </style>
</header>';
$currentHTML = ob_get_contents();
$finalHTML = str_replace('</header>', $foo, $currentHTML);

file_put_contents($options[$_POST['music1']].'+'.'and'.'+'.$options[$_POST['music2']].'.html', $finalHTML);


    }
    // end buffering and displaying page
    ob_end_flush();

    ?>
Positivity
  • 5,406
  • 6
  • 41
  • 61