That JavaScript solution is just ridiculous.
If you want "registration" on your site, the server should support a server-side language like PHP or ASP, and you'd need a database (typically MySQL for PHP or MS Access for ASP). You could then write it yourself or use something that's freely available.
If you're running the server yourself, you could simply download a LAMP stack (Linux, Apache, MySQL, PHP) or WAMP if you're running Windows.
If you have a hosting package, you probably already have access to a backend database and you can just set up a registration script to use that database to store user names etc.
But, if you just want authentication (a user name and password to access a file or directory), you can set that up with .htaccess files in Apache.