It's actually remarkably simple. thinking.php looks something like this:
//NOT ACTUAL CODE!
if (the_right_POST_data_exists()) {
print "<html><head><title>Thinking...</title></head><body onLoad=\"javascript: document.forms[0].submit();\">\n";
display_pretty_thinking_animation();
do_nasty_time_consuming_stuff();
print "<form action=results.php method=post>\n";
//...print out variables...
print "</form>\n";
print "</body></html>";
} else {
header_redirect("search.php");
}
I actually did it modally all on one page (i.e., I set a variable $mode according to whether it was search mode, thinking mode, etc.), but you get the idea from this. This way, the script loaded the "thinking" animation first and let the user stare at that while it did the nasty time-consuming stuff, after which it finished loading the page. (The animation, of course, continued while this happens; not a concern for high-bandwidth types, but it might be for modem-users, for whom the rest of the page might take a few seconds.) As soon as the page is done loading, the javascript redirects it to the "results" page (or mode, as it were). Furthermore, if the user goes to this page without POSTing to it from search.php (e.g., by hitting the "back" button from results.php), then it uses headers to transparently redirect the user back to search.php.
The code is really pretty simple; it was just figuring out how to start, and then it came together.