Fusioner
01-16-2012, 02:19 AM
i am having a simple login system, but i need some help i want to assign an if else statement my code is this :
what i need is if i login to sales if navigates to sales page,
if other then go to other page pls help me It is very important for me
Thanks is advance
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ENTER USER NAME ENTER PASSWORD</title>
<style type="text/css">
.style1 {
text-align: center;
}
</style>
</head>
<body style="background-color: #AFC8C7">
<script type = "text/javascript">
// Note: Like all Javascript password scripts, this is hopelessly insecure as the user can see
//the valid usernames/passwords and the redirect url simply with View Source.
// And the user can obtain another three tries simply by refreshing the page.
//So do not use for anything serious!
var count = 2;
function validate() {
var un = document.myform.username.value;
var pw = document.myform.pword.value;
var valid = false;
var unArray = ["HR", "Admin", "IT", "Sales"]; // as many as you like - no comma after final entry
var pwArray = ["hr123", "admin123", "it123", "sales123"]; // the corresponding passwords;
for (var i=0; i <unArray.length; i++) {
if ((un == unArray[i]) && (pw == pwArray[i])) {
valid = true;
break;
}
}
if (valid) {
alert ("Login was successful");
window.location = "index.html";
return false;
}
var t = " tries";
if (count == 1) {t = " try"}
if (count >= 1) {
alert ("Invalid username and/or password. You have " + count + t + " left.");
document.myform.username.value = "";
document.myform.pword.value = "";
setTimeout("document.myform.username.focus()", 25);
setTimeout("document.myform.username.select()", 25);
count --;
}
else {
alert ("Still incorrect! You have no more tries left!");
document.myform.username.value = "No more tries allowed!";
document.myform.pword.value = "";
document.myform.username.disabled = true;
document.myform.pword.disabled = true;
return false;
}
}
</script>
<form name = "myform">
<p> </p>
<p> </p>
<p> </p>
<p class="style1">User Name:
<input type="text" name="username" style="width: 131px">
</p>
<p class="style1"> Password: &nbs p;
<input type="password" name="pword" style="width: 131px">
</p>
<p class="style1"> & nbsp;   ;
<input type="button" value="Log In" name="Submit" onclick= "validate()" style="width: 96px">
</p>
</form>
<div style="position: absolute; width: 100px; height: 100px; z-index: 1; left: 136px; top: 252px" id="layer1">
</div>
<p> </p>
</body>
</html>
what i need is if i login to sales if navigates to sales page,
if other then go to other page pls help me It is very important for me
Thanks is advance
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ENTER USER NAME ENTER PASSWORD</title>
<style type="text/css">
.style1 {
text-align: center;
}
</style>
</head>
<body style="background-color: #AFC8C7">
<script type = "text/javascript">
// Note: Like all Javascript password scripts, this is hopelessly insecure as the user can see
//the valid usernames/passwords and the redirect url simply with View Source.
// And the user can obtain another three tries simply by refreshing the page.
//So do not use for anything serious!
var count = 2;
function validate() {
var un = document.myform.username.value;
var pw = document.myform.pword.value;
var valid = false;
var unArray = ["HR", "Admin", "IT", "Sales"]; // as many as you like - no comma after final entry
var pwArray = ["hr123", "admin123", "it123", "sales123"]; // the corresponding passwords;
for (var i=0; i <unArray.length; i++) {
if ((un == unArray[i]) && (pw == pwArray[i])) {
valid = true;
break;
}
}
if (valid) {
alert ("Login was successful");
window.location = "index.html";
return false;
}
var t = " tries";
if (count == 1) {t = " try"}
if (count >= 1) {
alert ("Invalid username and/or password. You have " + count + t + " left.");
document.myform.username.value = "";
document.myform.pword.value = "";
setTimeout("document.myform.username.focus()", 25);
setTimeout("document.myform.username.select()", 25);
count --;
}
else {
alert ("Still incorrect! You have no more tries left!");
document.myform.username.value = "No more tries allowed!";
document.myform.pword.value = "";
document.myform.username.disabled = true;
document.myform.pword.disabled = true;
return false;
}
}
</script>
<form name = "myform">
<p> </p>
<p> </p>
<p> </p>
<p class="style1">User Name:
<input type="text" name="username" style="width: 131px">
</p>
<p class="style1"> Password: &nbs p;
<input type="password" name="pword" style="width: 131px">
</p>
<p class="style1"> & nbsp;   ;
<input type="button" value="Log In" name="Submit" onclick= "validate()" style="width: 96px">
</p>
</form>
<div style="position: absolute; width: 100px; height: 100px; z-index: 1; left: 136px; top: 252px" id="layer1">
</div>
<p> </p>
</body>
</html>