JavaScript Issues...

timothyb89

New Member
Ok...
So I'm designing a JavaScript (obviously) to User and Password protect a webpage.
For some strange reason, it won't run, and I've managed to trace it to a seemingly nonexistant problem on line 27 (with "it (user == user1 || etc, etc) )

So here's my code:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
  <title>Your title here</title>

<script type="text/JavaScript">


/*WARNING! This script is untested. It functionality remains unknown.*/


//Varibles for User and Password to be inserted in. You shouldn't need to change these.
var user;
var pass;


//User info viribles. Don't use spaces in anything.
var u1="user1";
var u1pass="user1spassword";
var u1combine="user1user1spassword";

var u2="user1";
var u2pass="user1spassword";
var u2combine="user1user1spassword";

var u3="user1";
var u3pass="user1spassword";
var u3combine="user1user1spassword";

var u4="user1";
var u4pass="user1spassword";
var u4combine="user1user1spassword";

var u5="user1";
var u5pass="user1spassword";
var u5combine="user1user1spassword";

//Beginning of main script
user=prompt('Enter your username');

//User checking
if (user==u1 || user==u2 || user==u3 || user==u4 || user==u5)
{
	pass=prompt('User correct. Enter you password');

	//Checks password
	
	if (pass==u1pass || pass=u2pass || pass==u3pass || pass==u4pass || pass==u5pass)
	{
	}

	else 
	{
	window.location.href="badpassword.htm";
	}
}

else
{
window.location.href="baduser.htm";
}

//Checks user and password combination to make sure the password is owned by the user.

if (user+pass==u1combine || user+pass==u3combine || user+pass==u3combine || user+pass=u4combine || user+pass==u5combine)
{
}

else
{
alert("The user you entered is not associated with the password you entered");
window.location.href="badpair.htm";
}

/*End of script*/

</script>

</head>
<body>


</body>
</html>

So, does andone know what's wrong?
I know I have three syntax errors, and maybe someone can track those down for me? They may or may not be contributing to my problem...

And I don't really want it rewritten...
I just want to know what the problem is (it's the fact that it's "my code") and I really don't want to hear about JavaScript security. I'm just making this for some friends of mine.
 

possible.in

New Member
dont use javascript for user management,
the code is public and ur user management system can be bipassed easily.
rather use server side programming using ASP or PHP or something like that
 
Top