Ugh..
You don't need JavaScript!!
Ok the way in which you want to go about accessing to a restricted section.. there are several ways and I will list some of the more popular ones with brief explanations but first you need to tell us how secure you want this to be?
Like will you be coding an Internet banking system or just a 'members' page of a local club you got going, for example?
If it's an Internet banking system then I'd look at using sessions. There is information on these in the link i supplied in my aove post.
You can also use cookies (also explained in above link).
But by far the easiest and somewhat no so secure is the 'gdj27hdfuj0099fjhhf880kdjn999' named directory way of doing things.
You'd have a basic 'username' and 'password' form and if they are both the ones you want then the page would forward to this directory. If incorrect then the user is forwarded to the login page again. BUT, if a user knows what this directory name is then they could just type it in the URL.
I spose then you could disallow this by having the login page write a cookie upon successful login and everytime a page is opened in the 'gdj27hdfuj0099fjhhf880kdjn999' directory, the existence of the cookie is detected. If it exists then page opens. If not then user is redirected to before said login page.
Heh...so many ways of doing this 😃