I have had header problems before. On a page I did that had a problem, I fixed it with this:
<?
include ("db.php");
session_start();
if(!isset($uid)) {
echo("....")
etc. etc.
I am not sure what you are doing with the two lines:
header("Content-type: application/pdf");
readfile("/home/u409054/test.pdf");
but they might be a problem.