You have trailing new lines after the ?> at the bottom of each file, this causes a blank line to be emitted before header are sent and causes huge problems for other code.
Best practice is to never close the php code block so spurious new lines don’t break things!