in reply to Avoiding a second click

It sounds to me like your problem is that the CGI is not responding quickly enough to the user. I can think of at least 2 ways of presenting a "Please wait" screen to the user immediately, and then handling the expensive processing:

1. merlyn wrote up a nice solution a while ago. He forked a child process to do all the dirty work, which would be written to a session-specific file. The page would reload at 5 second intervals until the child process finished.

2. Alternatively, you could use the server push multipart MIME type. By printing a multipart/x-mixed-replace and then your "Please wait" page, you can then print the final resulting page whenever you're ready (from the same process).

- Richie