Click to See Complete Forum and Search --> : A Simple login function


Greelmo
05-14-2003, 01:59 PM
I think that this is just my computer being retarded, but i can't get this thing to work at all... I want a simple little form with an input and a password and a button. The user types there name and password, clicks the button, and gets on. I have only one user i want on this site because it is somewhat of a family gift. So, why isn't the following function working?:

<html>
<head>
<title>Please Login</title>
<SCRIPT LANGUAGE="JavaScript">

function fncdexter(texty, passy)
{
usern="Earl".toLowerCase();
userp="Hello".toLowerCase();
if (texty.toLowerCase()==usern && passy.toLowerCase()==userp){
alert("Login successful.");
location.href="http://www.geocities.com/dexweiss/motherday.html";}
else{
alert("Username/Password combination is incorrect.";}
}
</script>
</head>
<body bgcolor=#00ff00>
<form name="form1">
<input type="text" name="username">
<br>
<input type="password" name="userpass">
<input type="button" value="Login"
onClick="fncdexter(this.form.username.value, this.form.userpass.value); return false;">
</form>
</body>
</html>

any help is appreciated

Jona
05-14-2003, 02:02 PM
<html>
<head>
<title>Please Login</title>
<SCRIPT LANGUAGE="JavaScript">

function fncdexter(texty, passy)
{
usern="Earl".toLowerCase();
userp="Hello".toLowerCase();
if (texty==usern && passy==userp){
alert("Login successful.");
location.href="http://www.geocities.com/dexweiss/motherday.html";}
else{
alert("Username/Password combination is incorrect.");}
}
</script>
</head>
<body bgcolor=#00ff00>
<form name="form1">
<input type="text" name="username">
<br>
<input type="password" name="userpass">
<input type="button" value="Login"
onClick="fncdexter(this.form.username.value, this.form.userpass.value);">
</form>
</body>
</html>

Greelmo
05-14-2003, 02:07 PM
okay, so what if i have a homepage that opens that page in a new window, and in order to view the homepage, the person has to type in the password and name? Is that do=able? I guess it would use an onload thing on the homepage right? Could you post the source for the homepage if the URL of that page you just showed is "Login.html". Thanks Jona

Jona
05-14-2003, 02:12 PM
Not sure what you mean...

if (texty==usern && passy==userp){
alert("Login successful.");
window.open("http://www.geocities.com/dexweiss/motherday.html");}

Greelmo
05-14-2003, 02:14 PM
i want to pull up the source of what you just helped me with FROM another page, and i want it to open onLoad, so they have to get the password and name correct in the opened window to view the page that opened it.

Jona
05-14-2003, 02:18 PM
No, not for what you're asking for. Javascript can't do it. You should ALWAYS use a server-side language to logins anyways. ;)

Greelmo
05-14-2003, 02:36 PM
okay, thanks