You can only check the database afterwards.
Not in your php page script.
Because when connection is broke, the script will break.
However, there is a function to deal with such a situation.
To make sure a disconnect does not corrupt for example one upload/database insert.
[man]ignore_user_abort[/man]
— Set whether a client disconnect
should abort script execution
<?php
// Set PHP to Ignore user aborts and allow the script
// to run no matter if client is being disconnected
ignore_user_abort(true);
// perform your script here
?>