jonathanschiffe
02-11-2005, 04:17 PM
I'm trying to create and login and redirect on my home page for my clients. I am a designer not a coder, so I want something very simple (HTML, Jave Script). The scripts I have are close but I'm still not able to get a redirect. Thank you for any help.
Here are the scripts
HTML file
Index.html
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=macintosh">
<title>My Password Form</title>
</head>
<script language="JavaScript" type="text/JavaScript" src="login_password_info.js"></script>
<body>
<!-- BEGIN LOGIN FORM -->
<form name="login" action="javascript:nextPage()" method="POST" onsubmit="check_login(this)">
username: <input type="text" name="username" value=""><br>
password: <input type="pasword" name="password" value=""><br>
<input type="submit" value="SUBMIT" name="submit">
</form>
<!-- END LOGIN FORM -->
</body>
</html>
Java Script file
login_password_info.js
// ------- PASSWORDS AND REDIRECTS ---------
var login_array = [
["jon","athan","http://www.designiskinky.com"],
["cyn","thia","http://www.designinteract.com"],
["username","password","http://www.yahoo.com"]
];
// ------- FUNCTIONS ---------
function check_login (thisForm) {
for (var i in login_array) {
if (thisForm.username.value == "") {
alert("Please enter your username.");
thisForm.username.focus();
return false;
}
if (thisForm.password.value == "") {
alert("Please enter your password.");
thisForm.username.focus();
return false;
}
if ((login_array[i][0] == thisForm.username.value) && (login_array[i][1] == thisForm.password.value)) {
// alert(login_array[i][2]);
theURL = login_array[i][2]
document.location.href = theURL;
} else {
alert("Your username and password do not match our records. Please try again.");
return false;
}
}
}
Here are the scripts
HTML file
Index.html
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=macintosh">
<title>My Password Form</title>
</head>
<script language="JavaScript" type="text/JavaScript" src="login_password_info.js"></script>
<body>
<!-- BEGIN LOGIN FORM -->
<form name="login" action="javascript:nextPage()" method="POST" onsubmit="check_login(this)">
username: <input type="text" name="username" value=""><br>
password: <input type="pasword" name="password" value=""><br>
<input type="submit" value="SUBMIT" name="submit">
</form>
<!-- END LOGIN FORM -->
</body>
</html>
Java Script file
login_password_info.js
// ------- PASSWORDS AND REDIRECTS ---------
var login_array = [
["jon","athan","http://www.designiskinky.com"],
["cyn","thia","http://www.designinteract.com"],
["username","password","http://www.yahoo.com"]
];
// ------- FUNCTIONS ---------
function check_login (thisForm) {
for (var i in login_array) {
if (thisForm.username.value == "") {
alert("Please enter your username.");
thisForm.username.focus();
return false;
}
if (thisForm.password.value == "") {
alert("Please enter your password.");
thisForm.username.focus();
return false;
}
if ((login_array[i][0] == thisForm.username.value) && (login_array[i][1] == thisForm.password.value)) {
// alert(login_array[i][2]);
theURL = login_array[i][2]
document.location.href = theURL;
} else {
alert("Your username and password do not match our records. Please try again.");
return false;
}
}
}