You have some output like echo / print before the final output you are doing again which means you are sending the headers couple of times