Several problems needing to be addressed:
First, just an FYI. When the weekend rolls around, it can take a bit longer to get a reply/help, so be patient.
Second, $COOKIE[username] should look more like this:
$COOKIE['username'] (Note the single quotes around the index's name. Do the same with the password one.
Third, debugging 101... Change your query statements and add a die to them, so they will output the errors. This will help you troubleshoot the problems quicker.
$update = mysql_query("UPDATE users SET lastlogin = '$date' WHERE username = '$_COOKIE[username]'") OR die(mysql_error());
Report back after making these changes, and let's see if that has made any difference in fixing your issues, or if we need to continue on. If the die reports an error, then post back with that.