in reply to Premature end of script headers
In addition to what Corion said, consider using the CGI module. See Ovid's CGI Course - Resurrected and Updated! for further details.