Computing.Net > Forums > Programming > Javascript

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Javascript

Reply to Message Icon

Name: lime_sub
Date: April 26, 2002 at 18:51:35 Pacific
Comment:

I wonder i am in the right place to ask about javascript questions:
how do i code some page that
Users enter their login name and password
then the the script will open up a page for them.
Each user will have their particular page.
What i am try to do here is to do a manually coded database for each user.
Thanks



Sponsored Link
Ads by Google

Response Number 1
Name: Tom
Date: April 26, 2002 at 20:23:16 Pacific
Reply:

Well, you're not the first here to ask a JavaScript question =)
It is possible to do that with JavaScript, but since it's a client-side language, it will be very insecure. Maybe you should try using a server-side language such as ASP, PERL or PHP.


0

Response Number 2
Name: Jasmine
Date: April 27, 2002 at 00:02:42 Pacific
Reply:

Hey Tom, I bet you might be able to answer these questions of mine bout java script too :)
well i am confused of the codes in using form for password protection to my own homepage, can i do that?
I know the source for password and user, but how can the web verify their password is right or wrong?
what i really want is, to enter to the homepage, the user have to put in a correct password,... :P


0

Response Number 3
Name: lime_sub
Date: April 27, 2002 at 08:37:42 Pacific
Reply:

hey jasmine,
the web verify it your username and password wrong? Then you better recheck you HTML and Your javascript. they must be exactly the same. not even a single space
EX : (password) not (password ) <--a spacing

And Tom ,
i know its very insecure but i still want to do it. Because there is nothing private in my webpage. besides my webpage doesn't need $$$ to maintain. So it doesn';t support perl.
So can you help me with the coding on what i mention? Thanks


0

Response Number 4
Name: Tom
Date: April 27, 2002 at 10:04:55 Pacific
Reply:

Alright then, hopefully this will answer both of your questions.

You should have 2 arrays, one for the usernames, and one for the passwords. The corresponding password should be in the same place in the password array, as the username is in the username array. ie:
user[0] = "fred";
pass[0] = "fred's password";
user[1] = "steve";
pass[1] = "steve's password";
And so on. To get the username/password, you could either use:
var username = prompt("Enter username");
var password = prompt("Enter password");
or:
function getuser(){
var username = document.forms.userform.user.value;
var password = document.forms.userform.pass.value;
}
With the getuser() method, you should have an HTML form with name="userform", and 2 text inputs within the form, one name="user", and the other name="pass". With the password input, you could use type="password" instead of type="text". You would also have an input type="button" onClick="getuser()" (I can't type HTML tags on this board). You would then have a for loop:
var auth = false;
for(i = 0; i < x; i++){
if(username == user[i] && password == pass[i]){
auth = true;
// Whatever you want to do when authenticated, ie:
alert("Hello " + user[i] + "!");
location.href = "protected.html";
break;
}
}
if(!auth){
alert("invalid user/pass");
}
x should be the amount of users in total, the length of the arrays. If you were using the getuser() method, this loop should be inside the function.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Javascript

Javascript addition problem. www.computing.net/answers/programming/javascript-addition-problem-/14391.html

JAVAscript redirection www.computing.net/answers/programming/javascript-redirection/14338.html

Javascript look up www.computing.net/answers/programming/javascript-look-up-/9195.html