The problem of the header error is due to the wrong positions of lines.
You need to add the header line first.
Means put the line
print "Content-type: text/html\n\n";
before the "require" statement.
It will definitely solve your problem.
contact me if you have any other problem.
You can...