Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Login system Users

Status
Not open for further replies.

GRXboxers

Programmer
Joined
Feb 9, 2005
Messages
9
Location
NL
Heey I found this script somewhere on the Internet:

<script language="javascript">
<!--//
/*This Script allows people to enter by using a form that asks for a
UserID and Password*/
function pasuser(form) {
if (form.id.value=="Sixkiller") {
if (form.pass.value=="sixkiller") {
location="securepage.html"
} else {
alert("Invalid Password")
}
} else { alert("Invalid UserID")
}
}
//-->
</script>

<center>
<table bgcolor="black" cellpadding="12" border="0" height="100">
<tr><td colspan="2" height="38"><center><h1><span style="font-weight: 400">
<font color="#FF0000" face="Impact" size="5">Members Login</font></span></h1></center></td></tr>
<tr><td height="20"><h1><span style="font-weight: 400">
<font color="#FF0000" face="Impact" size="5">UserID:</font></span></h1></td><td height="20"><form name="login">
<input
name="id" type="text" size="20"></td></tr>
<tr><td height="55"><h1><span style="font-weight: 400">
<font color="#FF0000" face="Impact" size="5">Password:</font></span></h1></td><td height="55">
<input name="pass"
type="password" size="20"></td></tr>
<tr><td height="12"><center><input
type="Reset"></center></td><td height="12"><center><input type="button" value="Login"
onClick="pasuser(this.form)"></td></tr></table></center>
<script type="text/javascript" src="/i.js"></script>

Can anyone maybe tell me how to get more users in it, because the only user now is Sixkiller.

GRXboxers
 
You really should learn to indent your code, and use TGML code tags when posting - it makes things so much more readable.

You should also know that client-side "security" like this is so insecure it's virtually pointless. All someone has to do is view the page source, and bingo - all usernames and passwords are displayed, as well as the location of the "secure" pages. You really should avoid using this for anything that actually needs to be secure. Use server-side code instead.

But to answer your question anyway, the simplest way would be to add more if statements:

Code:
function pasuser(form) {
	if (form.id.value=="Sixkiller") {
		if (form.pass.value=="sixkiller") {               
			location="securepage.html"
		} else {
			alert("Invalid Password")
		}
	} else if (form.id.value=="Sixkiller2") {
		if (form.pass.value=="sixkiller2") {               
			location="securepage.html"
		} else {
			alert("Invalid Password")
		}
	} else {
		alert("Invalid UserID")
	}
}

There are better, more easily extensible ways, but as I said, it would be pointless spending any time making a good solution, when client-side security of this nature is not a good solution.

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top