banning code:
$f = fopen ('banned.txt','a');
fwrite ($bannedIp."\n",$f);
fclose ($f);
banned ip lookupcode:
$banned = file ('banned.txt');
if (in_array($_SERVER['REMOTE_ADDR']."\n", $banned)) {
header( 'Location: banned.html' ) ;
exit;
}
but yes, it's not a very effective way of stopping spammers, it's not very hard to change one self's IP.
you might consider other methods, such as preventing anyone from using the contact more than once every 30 minutes or so.