...

View Full Version : Need help for password code



jrolson
09-01-2004, 10:14 AM
I have this password code so far but I need to make it so after three wrong tries it will send you to a different page. Can someone please tell me how to make it work. Thanks

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function Login(){
var done=0;
var username=document.login.username.value;
username=username.toLowerCase();
var password=document.login.password.value;
password=password.toLowerCase();
if (username=="123" && password=="123") { window.location="privated.htm"; done=1; }
if (username=="321" && password=="321") { window.location="private.htm"; done=1; }
if (done==0) { alert("Invalid login!"); }
if (done==0) { window.location="new_page_3.htm"; done=0; }
}
// End -->
</SCRIPT>

Willy Duitt
09-01-2004, 11:39 AM
You can try something like this but I do not see the point... anyone can view source and quickly grab the username/password and bypass the entire script...



<script type="text/javascript">
<!-- Begin //
var hasTried = 1;
function Login(form){
if(form.username.value == 123 && form.password.value == 123){
form.action = 'privated.htm';
return true;
}
if(form.username.value == 321 && form.password.value == 321){
form.action = 'private.htm';
return true;
}
else if(hasTried < 3){
form.username.value = '';
form.password.value = '';
alert("Invalid login!");
form.username.focus();
hasTried++;
return false;
}
}
// End -->
</script>
</head>

<body>
<form method="post" action="new_page_3.htm" onsubmit="return Login(this)">
USERNAME: <input type="text" name="username">
PASSWORD: <input type="text" name="password">
<input type="submit" value="Test">
</form>


.....Willy



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum