Showing the correspondence between morphism of affine schemes and ring homomorphism is injective Let $X = \operatorname{Spec} A$ and $Y=\operatorname{Spec} B$ be affine schemes. For a ring homomorphism: $\varphi: B\rightarrow A$, we know that it naturally induces a morphism of locally ringed spaces $f: X\rightarrow Y$. Hartshorne discussed that this correspondence is surjective in chapter 2. However, what I have difficulty seeing is that this correspondence is injective. That is, given two ring homomorphisms $\varphi_1,\varphi_2: B\rightarrow A$ inducing the same morphism $f$, then $\varphi_1=\varphi_2$ necessarily.
I know that for the induced morphism $f^\sharp: (Y,\mathcal{O}_Y)\rightarrow(X, \mathcal{O}_X)$ one has, the map of stalks $f^\sharp_\mathfrak{p}$ is the localized map ${\varphi_1}_\mathfrak{p}= {\varphi_2}_\mathfrak{p}$ for all $\mathfrak{p}\in Y$.  How does one deduce from here that $\varphi_1=\varphi_2$?
I feel like I am missing something out simple so any help given would be greatly appreciated!
 A: You can observe that 
$O_X(X)\cong A$ 
where $O_X(X)$ is the Space of the global section of $X$.
Then if you have a morphism of scheme 
$(f,f^*): (X,O_X)\to (Y, O_Y)$ 
you get a morphism 
$f^*(A): O_X(X)\cong A\to (f_*O_Y)(A)\cong B$ 
This is the unique morphism which induces exactly $(f,f^*)$.
In fact if $\phi: A\to B$ is a morphism of ring which induces $(f,f^*)$, then for each $a\in A$, if we denote with $a^\sim\in O_X(X)$ the global constant section of $a$, we get 
$f^*(a^\sim)=\phi(a)^\sim$ 
so, up to isomorphism of $O_X(X)\cong A$, one get 
$f^*(a)=\phi(a)$
A: Assume that for every a in A we have f(a)/1=g(a)/1 in B_p for every p in Spec(B);
Assume there exists x in A s.t f(x)-g(x)=b is not 0 in B. 
In that case, 1*b=b which is not 0, so Ann(b) is a proper ideal in B and hence is contained in a maximal one m, which is a prime ideal. Now, Ann(b) and S=B\m have no common elements, but B_m=S^(-1)B, and f(x)/1=g(x)/1 in B_m - iff there exists s in S s.t s(f(x)-g(x))=xb=0 => s is both in Ann(b) and both in S - contradiction.
So we get f=g
