I have a site for filehosting. In the admin manager, I made a function when a user is deleted, the users uploaded data is compressed, and moved to another server.
The problem is when the admin clicks to delete a user, I would like a message saying "please wait while files are backed up.", but the backup function runs before the header, so you can't write output to the browser until the function is complete. So basicly the admin sees a blank page while the files are being backed up.
The setup is like this:
<?php
if(isset($_POST['submit']))
backupUser()
?>
<html>
<head><title></title></head>
<body>
<backup form>
</body>
</html>
The only way to do this is to include AJAX functionality using a framework (javascript) like jQuery.
The process would be like so:
References:
A probably better solution, for that kind of situations, would be :
update users set status = 2;
select * from users where status = 2;
With this :
You can even have the cron job run only during the night, when the server is not loaded, to avoid degrading its performances during the day, when it's used more.