Because all form variables get passed to the script. If you typed nothing, than it is an empty string, but is set. Your (first) condition should be:
if ($year != "")...
or, prettier:
if ($year == "")
echo ("You have entered a year.");
else
if (is_int($year))
echo ($year);
else
echo("You have entered a(n) " . (gettype($year)). ". You need to enter an integer.");
}