So many ways to do password protection depending on what you want to accomplish BEHIND the password and how much security you need.
Do you want everyone to use the same password?There are several other SCRIPTS for password protection (basically speed bumps and not real secure)
KW has some information here about a couple scrpts here.
Javascript is usually the ONLY way you can password protect on FREE hosts.
The new
CSB5 has a password protect feature. One password for ALL, can be changed when you want.
Read about the beta test here, works well. Check with your host as to WHICH page is supported on their server: ASP, PHP. Very nice, secure feature. You can change the password easily once a month, etc if you wanted....
Do you want each person to have a separate password and control the password assignment yourself?You could use the .htaccess file to define a full directory as password protected. That would use a user name and password.
Read about that here. This is a terrific way to block entry to the page for everyone else but the one with the password,
if your host supports it. Put up a simple signup form. You then assign a user name and password and email back to them. If you are on a WINDOWS server, this option is NOT available. If your WEB HOST offers CPANEL, you can QUICKLY password protect the folder and CPANEL will write your htaccess file for you! Easy and fast. I use this method to quickly put a MEMBERS area on a website for a homeowners association. Limited access to only those people with the password and they love it. This is also the option if you want to have limited access to files. Since the file is stored in a PROTECTED FOLDER, anything in that folder requires a password.
Do you want each person to have a separate password and have automated signup/emailing of password?Then you would need script/software to be installed on your server that would do that for you. Hotscripts.com has some MEMBER type scripts. Or a CMS script would do. The sample you gave us is a CMS script.