I have the below javascript function:
function pageRedirect() {
window.location.replace("ProdTypes.php");
}
setTimeout("pageRedirect()", 3000);
if($ptRowCount > 0) :
if ($ptQTYRowCount > 0):
$errors[]='Cannot delete or Archive product which has a Product Quantity > 0!!! Refreshing Page in 3 seconds...';
?>
<script>
pageRedirect();
</script>
<?php
elseif($ptQTYRowCount == 0):
$sql = "UPDATE producttype SET ProdTypeArchive='1' WHERE ProductTypeID = '$delete_id'";
$_SESSION['success_flash']='Product Type was Archived succesfully';
endif;
else:
$sql = "DELETE FROM producttype WHERE ProductTypeID = '$delete_id'";
$_SESSION['success_flash']='Product Type was deleted succesfully';
endif;
if ($ptQTYRowCount > 0):
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\aresV2\admin\includes\navigation.php:48) in C:\xampp\htdocs\aresV2\admin\ProdTypes.php on line 51
It is unclear from your question, but if you include the entire block of code in your page (the function + setTimeout statement), this causes the page to always reload after 3 seconds.
The solution would be to remove the setTimeout line, and in your if statement replace
?>
<script>
pageRedirect();
</script>
<?php
with
?>
<script>
setTimeout("pageRedirect", 3000);
</script>
<?php
As for the error you get when trying to redirect using headers, this has been answered before here on SO