I have an assignment and I think I am really close to completing it, but can't find exactly where the problem is. I have created a form that registers users. When the user completes the form and submits it, it should store cookies containing the user's information and display a dialog box that thanks them for registering. If the user attempts to register a second time with the same name, a dialog box should ask if they want to re-register. I am missing something, can someone please look at my code and help me out? I would really appreciate it!

Here is my code:

<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title> Marketing Seminar </title>

<script type="text/javascript">


function getCookie(c_name){
if (document.cookie.length>0){
c_start=document.cookie.indexOf(c_name + "=");
if (c_start!=-1)
c_start=c_start + c_name.length+1;
c_end=document.cookie.indexOf(";",c_start);
if (c_end==-1) c_end=encodeURI(document.cookie.length);{
return unescape(document.cookie.substring(c_start,c_end));
}
}
return "";
}

function setCookie(c_name,value,expiredays){
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
}

function registerForm(){
username=decodeURI(getCookie('username'));
if (username!=null && username!=""){
window.alert('Would you like to re-register?');
}
else{
window.alert('Thank you for registering!');
username= document.form1.fname.value
lastname= document.form1.lname.value
street= document.form1.saddress.value
ucity= document.form1.city.value
ustate= document.form1.state.value
uzip= document.form1.zip.value
if (username="");{
setCookie('username',username,365);
setCookie('lastname',lastname,365);
setCookie('street',street,365);
setCookie('ucity',ucity,365);
setCookie('ustate',ustate,365);
setCookie('uzip',uzip,365);
}
}
}
/* ]]> */
</script>

</head>
<body>
<h1>Marketing Seminar Registration</h1>

<h2>Name and Address</h2>

<form action="" >
<p> First Name: <input type="text" size="15" name="fname"/>&nbsp; &nbsp;
Last Name: <input type="text" size="15" name="lname"/></p>
<p> Street Address: <input type="text" size="50" name="saddress"/></p>
<p> City: <input type="text" size="30" name="city"/>&nbsp; &nbsp;
State: <input type="text" size="2" name="state"/>&nbsp; &nbsp;
Zip: <input type="text" size="5" name="zip"/></p>
<p><input type="button" name="submit" value="Submit" onclick="registerForm();"/></p>
</form>


</body>
</html>