How can the page be refreshed after deleting a record without causing a loop or immediate execution?

When deleting a record and refreshing the page immediately, it can cause a loop as the deletion process might not have completed before the page reloads. To prevent this, you can redirect the user to the same page after the deletion process is completed. This way, the page will be refreshed without causing a loop or immediate execution.

// Perform deletion process here

// Redirect to the same page after deletion
header("Location: {$_SERVER['PHP_SELF']}");
exit;