Explanation: You can't Append PHP inside the PHP tag. Hence you need to Resolve the Error as below. You have to concatenate the PHP with the Header Location Redirect.
if($ac == "yes"){
$message="Demo sold their product";
header( "Location: delete/delete.product.php?product=".$encodeCodeProduct); die;
} else{
$message="Demo did not sell their product";
header( "Location: delete/delete.product.php?product=".$encodeCodeProduct); die;
}
Error Would Likely Occur: If you face the Header Already Sent Error you have to clear the outputs that has been sent already with the help of ob_start()
before the header Redirection.
Redirection code with ob_start
if($ac == "yes"){
$message="Demo sold their product";
ob_start();
header( "Location: delete/delete.product.php?product=".$encodeCodeProduct); die;
} else{
$message="Demo did not sell their product";
ob_start();
header( "Location: delete/delete.product.php?product=".$encodeCodeProduct); die;
}
More Additional Reference from SO: How to fix "Headers already sent" error in PHP