click here takes all the headaches out of password protecting pages.
It is a 30 day trial after which you must buy it in order to continue using it.
It's drop dead easy to use and very effective, and will run quite happily on your WebMania account.
If you want to manually wrestle with scripts run a search on Hotscripts.com for password protection in either the Perl/CGI or PHP categories.
I'd go for the CoffeeCup product myself though, and spend the time you would have wasted wrestling with a script thinking lofty thoughts instead.