JavaScript Log-in Page
Hello TWF Members
I have a few problems
I need people to log in to my site and have it remember their UserNames and passwords the whole time.
1st problem: When I execute the .pl script to set the cookie, it gives me "method: post is not allowed on this server"(Not sure what kind of problem this is)
It is my own server, but I didn't find anything about POST not being allowed
2nd problem: It tells me "UserName is undefined"
The script is below
Please troubleshoot for me.Thanks
<html><script language=javascript>
function getCookie(NameOfCookie)
{ if (document.cookie.length > 0)
{ begin = document.cookie.indexOf(NameOfCookie+"=");
if (begin != -1) {
begin += NameOfCookie.length+1;
end = document.cookie.indexOf(";", begin);
if (end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(begin, end)); }
}
return ;
}
function setCookie(NameOfCookie, value, expiredays)
{ var ExpireDate = new Date ();
ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
document.cookie = NameOfCookie + "=" + escape(value) +
((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}
function delCookie (NameOfCookie)
{ if (getCookie(NameOfCookie)) {
document.cookie = NameOfCookie + "=" +
"; expires=Thu, 31-Jan-70 00:00:01 GMT";
}
}
</script>
</head><body background=bgg.jpg bgcolor=green visited=red link=white></center><centeR><font color=lime size=5>Report A Loss</font></center><br><font color=white size=2>
<form name=form method="post" action="report3.cgi">
Your Login Name:<input type=text name=UserName><BR>
Your Password:<input type=password name=Password><BR>
<p>OPPONENT: <input type="text" name="opp"><p><input
<input value=Report type=submit>
<script language=javascript>
// this checks to see if the UserName and Password cookies are set
// if they are, this will fill in the login form for the user
// but the user still has to click "submit"
if (getCookie(UserName) != Null ) {
document.form.UserName.value=getCookie(UserName);
}
if (getCookie(Password) != Null ) {
document.form.Password.value=getCookie(Password);
}
</script>
Mark Hensler posted this at 04:42 — 24th March 2001.
He has: 4,048 posts
Joined: Aug 2000
the functin GetCookie takes a string as an arguement....
if (getCookie("UserName") != Null ) {
if (getCookie("Password") != Null ) {
not
if (getCookie(UserName) != Null ) {
if (getCookie(Password) != Null ) {
Mark Hensler
If there is no answer on Google, then there is no question.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.