TITLE: Injective map on coordinate ring implies surjective?
QUESTION [8 upvotes]: Suppose that $f:X\rightarrow Y$ is a morphism between two affine varieties over an algebraically closed field $K$.
I believe that if the corresponding morphism of $K-$algebras, $f^\ast:K[Y]\rightarrow K[X]$ is injective, it is not necessarily true that $f:X\rightarrow Y$ must be surjective but I have yet to come up with a counterexample. 
Is there such a counterexample?

REPLY [7 votes]: Given a morphism of rings $\phi:A\to B$ and the corresponding morphism of affine schemes $\sideset {^a}{} \phi=f:Spec (B)\to Spec(A)$, we have the equivalence: $$ f (Spec(B))\:  \text {is dense  in}\:  Spec(A)\iff   \text {Ker } (\phi) \subset \text {Nil} (A)$$  From this   it is very easy to find injective morphisms of rings $\phi:A\to B$ with associated non surjective morphisms $ f:Spec (B)\to Spec(A)$.   
For example if $A$ is a domain and $0\neq a\in A$, then the inclusion morphism $\phi:A\to A_a=A[\frac {1}{a}]$ yields the inclusion $\sideset {^a}{} \phi=f:Spec (A_a)\to Spec(A)$, which is not surjective as soon as  $a$ is not an invertible element of $A$. (Qiaochu's example is of that type)