The password protect code must proceed everything else on the page. It must be encountered before the header is written since a header cannot be changed once written. The password protect script alters the header, so if you have already written a header, it will not work. Instead of putting the password protect script into your site template, try incorporating a modified version of your site template into the password protect script. Despite what it says, you can actually modify the code in the section labeled (do not change code below.) You can put whatever you want between the <HTML> and </HTML> tags including page banners, references to CSS pages, etc. Just make sure to include the key functional elements of that section which would be the META tags, the form-related lines, and the PHP code. Here are two sites that I have posted that display the Password Protect Login Page using the existing site template. The first is a demo site, so you can download the code that I used. Just click on EDIT at the bottom of the page to see how the Password Protect Prompt is displayed using the same website framework as the rest of the site.
Demo URL:
http://www.iwonderifthiswillwork.com/cms-demoWorking Example URL:
http://aprs.ohioares10.org