Is there a way to ensure the below code, is executed in one go (so if the visitor presses escape on keyboard or closes browser, it won’t just execute half way. It’s important they are all done in one go or none at all).
mysql_query($queryone);
mysql_query($querytwo);
unlink($file);
unlink($thumb);
mysql_query($querythree);
Appreciate all replies and example code would be nice.
Chances are those statements would all execute if the user stopped their browser, but to ensure that they do, add
ignore_user_abort(true);before those statements to tell PHP not to terminate if it detects a client disconnect.See the
php.inisetting ignore_user_abort. This will allow the script to run to completion whether or not the client is still connected.Further reading:
http://www.php.net/manual/en/features.connection-handling.php