This is going to be wrong for some of your users, because some ZIP codes cross state boundaries. So you'd need to let them correct the guess in that case. It is unusual for one zip code to be in two states, but it does happen. [1]
It's also going to be wrong for military addresses, as I understand it. [2]