leong61
07-14-2003, 11:19 PM
The purpose of generating this cookies is for a login form to accept a user id and password and greets the user upon successful login using cookies.
My codes are as follows but cannot work. What should I do?:-
Login Form.html :-
<html>
<meta name="author" content="LYK">
<link rel=stylesheet href="stylesheet.css" type="text/css">
<head>
<title>Login Form</title>
<script language="Javascript" type="text/javascript">
alert("You have reached a Members-Only Site");
function Get_Cookie(name)
{
var start = document.cookie.indexOf(name+"=");
var len = start+name.length+1;
if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
if (start == -1) return null;
var end = document.cookie.indexOf(";",len);
if (end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(len,end));
}
function Set_Cookie(name,value,expires,path,domain,secure)
{
document.cookie = name + "=" +escape(value) +
( (expires) ? ";expires=" + expires.toGMTString() : "") +
( (path) ? ";path=" + path : "") +
( (domain) ? ";domain=" + domain : "") +
( (secure) ? ";secure" : "");
}
function myfunction()
{
if (login.userid.value=="")
{
alert("Please enter your userid");
login.userid.focus();
login.userid.select();
return false;
}
if (login.password.value=="")
{
alert("Please enter your password");
login.password.focus();
login.password.select();
return false;
}
}
</script>
</head>
<body>
<marquee><h1><font color="#A01080">Welcome to Login Page!!!!!</h1></font></marquee>
<form name="login" method="post" onSubmit="return myfunction()" action="">
<table align="center">
<tr><td><font><b>UserID</b></td><td><input type="text" name="userid" size="20" maxlength="50" value=""></td></tr>
<tr><td><font><b>Password</b></td><td><input type="password" name="password" size="20" maxlength="50"></td></tr>
</table>
<table align="center">
<tr><td><input type="submit" value="Login">
<input type="submit" value="Reset"></td></tr>
</table>
</form>
<b>* <i>If you do not have a userid and password, please </i><a href="Registration Form.html">REGISTER</a>.</b><br>
<b>* <i>If you forgot your userid or password, please </i><a href="mailto:lyk@hushmail.com">email</a> me.</b>
</body>
</html>
home.html:-
<html>
<meta name="author" content="LYK">
<link rel=stylesheet href="stylesheet.css" type="text/css">
<head>
<title>Home Page</title>
</head>
<body >
<h1>Welcome to the HomePage!!!</h1>
</body>
</html>
My codes are as follows but cannot work. What should I do?:-
Login Form.html :-
<html>
<meta name="author" content="LYK">
<link rel=stylesheet href="stylesheet.css" type="text/css">
<head>
<title>Login Form</title>
<script language="Javascript" type="text/javascript">
alert("You have reached a Members-Only Site");
function Get_Cookie(name)
{
var start = document.cookie.indexOf(name+"=");
var len = start+name.length+1;
if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
if (start == -1) return null;
var end = document.cookie.indexOf(";",len);
if (end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(len,end));
}
function Set_Cookie(name,value,expires,path,domain,secure)
{
document.cookie = name + "=" +escape(value) +
( (expires) ? ";expires=" + expires.toGMTString() : "") +
( (path) ? ";path=" + path : "") +
( (domain) ? ";domain=" + domain : "") +
( (secure) ? ";secure" : "");
}
function myfunction()
{
if (login.userid.value=="")
{
alert("Please enter your userid");
login.userid.focus();
login.userid.select();
return false;
}
if (login.password.value=="")
{
alert("Please enter your password");
login.password.focus();
login.password.select();
return false;
}
}
</script>
</head>
<body>
<marquee><h1><font color="#A01080">Welcome to Login Page!!!!!</h1></font></marquee>
<form name="login" method="post" onSubmit="return myfunction()" action="">
<table align="center">
<tr><td><font><b>UserID</b></td><td><input type="text" name="userid" size="20" maxlength="50" value=""></td></tr>
<tr><td><font><b>Password</b></td><td><input type="password" name="password" size="20" maxlength="50"></td></tr>
</table>
<table align="center">
<tr><td><input type="submit" value="Login">
<input type="submit" value="Reset"></td></tr>
</table>
</form>
<b>* <i>If you do not have a userid and password, please </i><a href="Registration Form.html">REGISTER</a>.</b><br>
<b>* <i>If you forgot your userid or password, please </i><a href="mailto:lyk@hushmail.com">email</a> me.</b>
</body>
</html>
home.html:-
<html>
<meta name="author" content="LYK">
<link rel=stylesheet href="stylesheet.css" type="text/css">
<head>
<title>Home Page</title>
</head>
<body >
<h1>Welcome to the HomePage!!!</h1>
</body>
</html>