What I’m trying to do is setup a username/password through a cookie. I have the cookie portion setup but i’m not sure how to do the password and username. I am trying to setup an “IF” statement that would comapre username.value and password.value from the cookie itself through a string.
Here is my code, I’m not sure where to start with this, could someone provide some insight?
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “
<html><head><title>Project 8-3</title></head>
<body>
<strong><center><p> Welcome to the most interesting website you have seen in years. Yes, I realize that this doesn’t do much,
but I don’t know a whole lot about Internet programming so just lay off and enter your username and password
and we will all get along. Oh, and don’t make me check whether you entered your password correctly cause that
makes even more work for the guy running this damn thing! Thanks and have a wonderful day.</p></Center></strong>
<center> <p> Make sure that you password is no longer than 16 characters, thanks!</p></center>
<FORM Action “”>
<center> Username: <input type =”text” name=”userName”> <br /></center>
<center> Password: <input type =”password” name=”passWord” maxlength =”16″><br /></center>
<center><input name=”submitButton” value=”Enter” ;=”” type=”button” onClick=”return ChckPassWrd();”></center>
</FORM>
<script type=”text/Javascript”>
<!–HIDE FROM INCOMPATIBLE BROWSERS
function ChckPassWrd(){
if (document.forms[0].userName.value != ” “)
{
window.alert (“You have not entered a username”);
document.forms[0].userName.focus(); //set the cursor back to username text
return true;
} // trying to set this so once text is entered it goes to password
else { (document.forms[0].passWord != ” “)
window.alert (“You have not entered a password”);
return false;
document.forms[0].passWord.focus(); //set the cursor back to password field
}
}
function setcookie(){
var expiresDate = new Date ();
expiresdate.setfullyear(expiresDate.getfullyear() +1);
document.cookie = encodeURI(“userName=” + document.forms[0].userName.value) + “; expires=”
+expiresDate.toUTCString();
document.cookie = encodeURI(“passWord=” + document.forms[0].passWord.value) + “; expires=”
+expiresDate.toUTCString();
}
//STOP HIDING FROM INCOMPATIBLE BROWSERS –>
</script>
</body>
</html>