[eluser]BrianDHall[/eluser]
If you want to run a PHP process in the background this is annoyingly non-trivial on windows - but is possible, and on unix is easy.
This is one of those things that you think should be easy, because even Perl has this thanks to Fork()...but PHP doesn't. Go figure.
Anyway, basically what you do is either as gon suggests above with a cronjob, or you need your script to execute another script in the background using exec() (linux only) or popen() (windows or unix).
I got this code from the exec() listing in the php manual
[code]
<?php
function execInBackground($path, $exe, $args = "") {
global $conf;
if (file_exists($path . $exe)) {
chdir($path);
if (substr(php_uname(), 0, 7) == "Windows"){
pclose(popen("start \"bla\" \"" . $exe . "\" " . escapeshellarg($args), "r"));
} else {
exec("./" . $exe . " " . escapeshellarg($args) . " > /dev/null &");
}
}
}
?> [/close]
Yeah, so having a 'fork' helper would be damn nice, wouldn't it?
Anyway, this is obviously not a beginner solution.
The easier way is to give them an 'interstitial' page that gives them the 'please wait thing', with a few second delay javascript redirect to the real page.
...yeah, I would strongly recommend that way.