Well recording an IP address is a bit of a tricky thing and this opens up a big topic.
If the user is coming through a proxy or a gateway their IP address might be in the $SERVER['HTTP_X_FORWARDED_FOR'] variable. If the proxies bothered to fill it in. When coming through a proxy the $SERVER['REMOTE_ADDR'] will contain the IP address of the proxy server and not the user's IP address. Also, the user may have gone through several proxies, so the $_SERVER['HTTP_X_FORWARDED_FOR'] variable could contain several IP addresses separated by commas. The last one should be the users. All this can be faked.
Even if they're not going through a proxy, user's using ISP like AOL will come through different IP addresses per HTTP request. They can jump around across full networks - i.e. one request could come from 1.2.3.4 and the next could be 5.6.7.8 (as opposed to 1.2.x.x something).
Capturing the IP is still important though and can then allow you to do a whois lookup. Also, you can resolve the address within PHP by using the gethostbyaddr() function. Run trace routing on it too.
You can build in a feature to block certain IP addresses within your code including using cookies to ban. If you're using Apache server, then you can block an IP using a .htaccess file.
FYI: Please note that the header() with location command does not redirect right there and then when it's executed. It actually redirects when your script ends or an exit is reached. So, to ensure no logic flow problems in your script, you should have an exit right after every header() with location to force redirection to occur immediately.
hth.