Hi Everyone,
I want to do two things on the same page in PHP. The first is quick and I want to output the result to the client (this works). The second takes a long time and depends on the result of the first. Basically what I would like to do is:

However, I don't know how to close the client connection. The client's browser sits there waiting for the script to end.

One other solution I think would be to use "system()" to start a CGI script. Two problems, I don't know how to compile and run PHP as a CGI script, and I don't think I have a PHP binary executable on my host.

Yup, I've read the section on connection handling. Unfornately it only deals with what happens if the client closes the connection during execution of the script. It doesn't describe how to close the connection and continue script execution (or really anything to do with server side control of the connection).

1. Send a URL header to redirect the browser to another page, such as:
<?
header ("Location: your_logout_page.php?a_variable_if_you_want_one=$foo");
?>
(normally one would call the 'exit;' command afterward to end any further execution of the present script, but in your case, you would just want to call the header, and redirect the browser while the script finishes execution.)

2. If you want the page to close completely just use the javascript function window.close(). You could use it in <form onsubmit="window.close()"> or in your submit button with the 'onclick' event handler. The user will be prompted for authorization to close the page, though.

Yes, you have no real server-side control of the client connection, because there is no true 'connection' -- such as a socket -- with HTTP. But one (or both) of the above will be the next best thing.