I don't think the query parameters are passed to includes. Try dumping out the query string in your CGI to check. I'd suggest calling your CGI directly and having it include the header and footer. You could even use SSI-like syntax for that, with one of the SSI modules on CPAN.