I know it says 'contact me by email', but that sort of defeats the point of the forum, no?
Anyway, a simple solution would be to create your template (with navigation, etc), and put a php tag like <? print($output); ?> in the template where you want your content to appear. Your 'cgi' script could then create a $output string with all your content/html (you could even use output buffering in php4), and you could just require("template.php3"); at the end of the script.
For a more robust solution, try looking at:
http://phpclasses.upperdesign.com/browse.html/class/1
where you'll find a few solutions to your problem.