View Full Version : Creating A Login Page

05-07-2006, 01:19 AM
Simply, I would like to know how to create a login page. To my knowledge, this task is relatively easy. However, due to my lack of knowledge of Java/Javascript, I am immensely stuck.

Given the following (a very simple Username/Password login area -- as I have posted (below) and shown here: http://www.geocities.com/simple_userpass/index.htm )...


<form name='main' method='INeedAMethod' action='INeedAnAction'>
<input type='hidden' name='cmd' value='INeedAValue'>

<table border='1' bgcolor="#CCCCCC">
<input type='text' name='j_username' size='10' maxlength='25' >
<input type='password' name='j_password' size='10' maxlength='25' >
<input type='submit' value='Login'>


...how can I create a login page that allows only authorized users to be redirected to the main webpage. I presume this would be similar to that of a forum's Login page, as you must login in order to post (and have other capabilities). However, for my Login page, I do not want to allow 'guests' to roam the webpage. If a guest wants access to the webpage, they must email an administrator that will then determine their eligibility. This login page is meant to only allow those eligibile to view the information on the webpage. The goal is to make everyone that accesses the domain pass through this step before they can access the information therein.

Naturally, since I don't have much knowledge on the subject, as mentioned above, feel free to explain to me (the many) other 'things' I would need. I feel that this process is pointless unless there is a 'document' that checks the inputted username/password with the username/password in a file somewhere else.

If there is a premade login page already created, where I would have to simply change the fields, that may also be helpful.

The username/password fields in the given login page (above) are not final, so if someone wants to 'shred' my code, be my guest.

If you don't mind, please leave a means of communication where I would be able to reach you, else I'll post in this thread.

Thank you very much for any help.


05-07-2006, 01:38 AM

there are many ways of doing what you want to do, but none of them include javascript!

You need to use a Serverside script, like php, asp, or perl.

I think along with many other users on the forum, i would recommend PHP.

There are still a few ways you can do it, how secure do you need it to be? You can store the username and password in a text file and put it on the server, or you can store the usernames and passwords in a database and have the script look in there for it.

As far as your form goes, the method you would use would be "post" and the action would be the name of the script that you will be using i.e. login.php.

Another option would be to use .htaccess files, but i havent heard people talking about them for a long time, so im not sure whether anyone else would still recommend them, also not sure how secure this method would be.


Philip M
05-07-2006, 07:41 AM
A server-side script is naturally to be preferred, but a secure log-on can be
achieved with JavaScipt.

See Borgtex's ingenious scripts at


05-07-2006, 10:52 PM
Thank you Jonny and Philip. You both have been very helpful.

To answer: I need the site to be secure enough so that people can't just pass over the initial login stage, and must enter username/password to get access. Additionally, I can't have it possible for 'hackers' to read the files in my directory and thus get alternate ways of accessing protected webpages.

Moreover, if I were to make a server-side script, how would I go along trying that?

05-07-2006, 11:30 PM
You can't create a secure page using Javascript as there are always ways of obtaining the page source bypassing the Javascript. The closest you can get would be to "encrypt" the web page and require a password to be entered in order to "decrypt" it (as described at the bottom of http://www.felgall.com/javatip4.js ). Even then someone could just analyse the Javascript code in the page in order to decrypt the content without needing to know the password.

05-08-2006, 04:04 AM
Your best bet I think would be to use some kind of server-side language like Jon suggested. I can only assume Geocities supports one if not more of these. You should find out what they support before you go researching server-side languages (unless anyone else here knows).

05-08-2006, 06:00 PM
I am using geocities for testing, but I doubt I will use it for the final webpage.

Otherwise, I would love to use a server-side language, as it seems to be the most secure.

Now the question is: How should I go about creating this page using a server-side language? It seems PHP has the most popularity. Ergo, should I create the same thread in the PHP forum?

Thanks for the help felgall and thesmart1!

05-08-2006, 06:37 PM
i think along with many other members i would recomment going to www.w3schools.com and reading through the pages on PHP and MySQL, as you will need at least a basic understandin of php and mysql before you can create even a simple login script.

Have a quick read just to familiarise your self with both langauges, then it will make more sense when we explain what you need to do.

Hope that helps


05-10-2006, 06:19 AM
Thanks again for the help Jonny.

I'm sorry if this sounds pathetic (or simply lazy), but...
Would it be possible to find a (server-side) login script already made, where I would only have to change (a majority of) the fields.

Philip M
05-10-2006, 07:39 AM
You will find quite a few pre-made (free) scripts at www.hotscripts.com.

A good example is to be found at