If I understand correctly what you are trying to accomplish then there are a couple of ways to do this. What you need to do is get all the html from process.php into a buffer or a variable so you can write it to result.html.
If you are using PHP4 then you can use output buffering. This captures all output into an internal buffer which allows you to easily save it into a file. An example:
//Turn output buffering on at the
//start of your page
<?php
ob_start();
?>
<head>..etc
all the html you want
<?php
print "Nothing is sent to the browser until I flush the internal buffer";
// Write the contents of the buffer to results.html
// using ob_get_contents()
$newFile = @fopen("result.html", "w+");
if($newFile) {
fwrite( $newFile, ob_get_contents() );
} else [
//The file couldn't be opened for writing
}
//Now you can output everything to the broswer
ob_end_flush();
?>
There is a slight performance hit for doing this but it is a very easy way of writing out files created by PHP. Plus you can serve results.html to visitors after it has been created instead of process.php.
If you aren't using PHP4 then you can put all your content into a variable like this:
<?php
$outputVar = "<head></head>\n<body>...";
$outputVar .= "All content goes into a variable";
// Write the contents of $outputVar to
// results.html
$newFile = @fopen("result.html", "w+");
if($newFile) {
fwrite( $newFile, $outputVar );
} else [
//The file couldn't be opened for writing
}
//Now print off the content for visitors
print $outputVar;
?>
You could also use templates, which store everything in variables before outputing, and output that information to a file as well. Check out the manual for more information on output buffering, etc.
Trevor DeVore
Blue Mango Multimedia