put the header statement in the if clause that sets the cookie.
Also, you want to call ShowVotes() back on the index page after you have tested to see if the cookie exists.
so:
$strQuery = "INSERT INTO pollAnswers VALUES(";
$strQuery .= "0, $pollId, '$answer', '$visitorIP')";
if(mysql_query($strQuery))
{
setcookie("has_voted_" . $pollId, 1, time() + 3600 * 24 * 30);
// ShowVotes(); // this should be called on the next page after testing for the cookie set above
header("location: index1.php");
}
?>