in reply to How to include php-code in header
I see nothing in what you posted that can't be done with Perl and CGI. Is there some local condition that makes that unacceptable?