I removed this line
<?php echo((isset($_COOKIE["ipaddress"]))?$_COOKIE["ipaddress"]:"") ?>
from line 1, but it's still not redirecting. I also was not receiving the "headers already sent" message. There were no errors at all. I only added that statement after it wasn't redirecting - to make sure that it was actually capturing the IP address.