/    Sign up×
Community /Pin to ProfileBookmark

Login In with Multiple Usernames and Passwords

I am looking for a code that requires that you have a username and a password, however there are multiple usernames and passwords but they all end up to the same place. Is this possible. I found quite a few codes on Javascriptkit.com but none of them had what I wanted. My idea is that all passwords and usernames go to the same page, but it just makes it seem that they have their own personal password (which I will encript for security matters.) Any suggestions?

to post a comment
JavaScript

13 Comments(s)

Copy linkTweet thisAlerts:
@JMRKEROct 16.2006 — Since you are not asking for any JS validation of the input, this should serve your purpose:
[code=php]
<html>
<head>
<title>User-Password</title>
</head>
<body>
Username: <input type="text" value="">
Password: <input type="password" value="">
<button onClick="window.location='http://www.anywhere_you_want_to_go.com'">Go</button>
</body>
</html>
[/code]

No matter what you enter, it goes to the same place.

Not sure if that will fool too many people, but you can try.

You could add an array of usernames that are allowed and let the password validation occur in a server-side script as it will not be very secure in JS.
Copy linkTweet thisAlerts:
@felgallOct 16.2006 — Since anyone can read the Javascript code to find out the password yo can't use Javascript to effectively provide password protection of anything. Only where the password is part of the filename does it provide any protection at all.
Copy linkTweet thisAlerts:
@youngdesignerauthorOct 16.2006 — But how do you require both a set of multiple usernames and passwords? What you gave me is just if they type anything at all they get there, what I would like is that they have to have the right password and username (there are multiples of these) in order to get to the certain page.
Copy linkTweet thisAlerts:
@JMRKEROct 17.2006 — Change to:
[code=php]
<html>
<head>
<title>User-Password</title>
<script type="text/javascript">
// would suggest hiding following info server-side
Users = new Array('User1','User2','User3');
PassWds = new Array('Pass1','Pass2','Pass3');
function Validate() {
var User = document.getElementById('UserName').value;
var Passwd = document.getElementById('PassWord').value;
for (item=0; item<Users.length; item++) {
if ((Users[item] == User) && (PassWds[item] == Passwd)) {
window.location='http://www.anywhere_you_want_to_go.com'
}
// does not go anywhere unless match of User AND Passwd with arrays of Users AND PassWds
}
}
</script>
</head>
<body>
Username: <input id="UserName" type="text" value="">
Password: <input id="PassWord" type="password" value="">
<button onClick="Validate()">Go</button>
</body>
</html>
[/code]

Still not a very good job at security, IMHO, but it does what you originally asked it to do.
Copy linkTweet thisAlerts:
@youngdesignerauthorOct 17.2006 — It still didnt work. Go try it out and maybe you will see what is wrong.

Username: visit

Password: go
Copy linkTweet thisAlerts:
@JMRKEROct 17.2006 — If I understand your question correctly, then yes.

Inorder to GO to the site, both the Username and Password must match.

Give it a try to see how it works.

If you want, alert the user if they give invalid entries, like:
[code=php]
for (item=0; item<Users.length; item++) {
if ((Users[item] == User) && (PassWds[item] == Passwd)) {
window.location='http://www.anywhere_you_want_to_go.com'
}
}
alert('Invalid entries');
[/code]
Copy linkTweet thisAlerts:
@youngdesignerauthorOct 17.2006 — Check my updated question, cause it wont work.
Copy linkTweet thisAlerts:
@youngdesignerauthorOct 17.2006 — ^Bump^ I found a really cool code from a website that I think works wonders. Thanks for your help!
Copy linkTweet thisAlerts:
@JMRKEROct 17.2006 — Change this line:

if ((Users[item] == User) && (PassWds[item] == Passwd)) {

In your script, it has PassWd'
Copy linkTweet thisAlerts:
@felgallOct 17.2006 — Of course if you use Javascript then anyone can access the site because anyone can read the Javascript to see what the password is.
Copy linkTweet thisAlerts:
@youngdesignerauthorOct 18.2006 — Yeh, I realized that. But what I am planning to do is make it into a image map, and dissallow right click. Then I would be able to prevent it somehow. I understand that they can still view it, but not everyone knows how to read html.
Copy linkTweet thisAlerts:
@JMRKEROct 18.2006 — Then I would be able to prevent it somehow.[/QUOTE]

I believe 'somehow' is the operative word. ?
Copy linkTweet thisAlerts:
@youngdesignerauthorOct 27.2006 — Yeh, your right!
×

Success!

Help @youngdesigner spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...