Morphism between affine scheme corresponding with ring homomorphism Let $X = \text{Spec} R$ and $K = \text{Spec} S$ be two affine schemes with $f,g: K \rightarrow X$. I know that a morphism between affine schemes correspond with a ring homomrphism, so denote $\varphi: R \rightarrow S$ the map that corresponds with $f$ and $\psi$ that corresponds with $g$.
Let $y = [\mathfrak{p}] \in K$ be a point and suppose $f(y)=g(y)=x=[\mathfrak{q}] \in X$. A friend of mine said that the following is true:
$$f^\#_x = g^\#_x: k(x) \rightarrow k(y) \Leftrightarrow \forall r \in R: \varphi(r) \equiv \psi(r) \text{ mod } \mathfrak{p}$$
where $k(x)$ and $k(y)$ are the residue fields of their corresponding stalks.
I don't know if it is even true. Can anybody give a counterexample or a proof?
 A: $\def\p{{\mathfrak{p}}}
\def\q{{\mathfrak{q}}}$
Somebody gave me the answer, so I thought it would be best to post it here as well. I will use the following diagram (which can actually be seen as 2 separate diagrams) to prove this:
$$\require{AMScd}
\begin{CD}
R @>\varphi, \psi>> S\\
@VV\pi_\p V @VV\pi_\q V\\
R/\p @>\alpha_1, \alpha_2>> S/\q\\
@VVm_1V @VVm_2V\\
k([\p]) @>f^\#_x, g^\#_x>> k([\q])
\end{CD}$$
All the vertical arrows always exist, all the arrows in the middle are induced by $\varphi$ and $\psi$. Clearly holds $\p \subset \ker(\pi_\q\circ \varphi)$ (equality holds but that is not important), hence $\pi_\q\circ\varphi$ factors over $\alpha_1$. In the same way $\alpha_2$ is induced from $\psi$. Note that we have $\alpha_1$ is injective, since we mod out by the kernel of $\pi_q\circ \varphi$, same for $\alpha_2$.
Use the notation $x = [\q]$ and $y=[\p]$. We have $y = f(x) = g(x) \Leftrightarrow \varphi^{-1}(\q) = \psi^{-1}(\q) = \p$. Note that holds $k([\p]) \cong \text{Frac}(R/\p) \cong R_\p/\p R_\p$. So the map $m_1$ is just the injection of the domain $R/\p$ into its fraction field. Hence $m_1$ and $m_2$ are injections. Clearly $f^\#_x$ and $g^\#_x$ are injections because they are morphisms between fields.
$\Leftarrow$. Assume $\pi_\q \circ \varphi = \pi_\q \circ \psi$. I already stated that both maps factor over $\alpha_1$ and $\alpha_2$. Since they are the same map, we have $\alpha_1 = \alpha_2$.
Now we can consider the second square. Consider the map $m_2 \circ \alpha_1$. Both maps are injective, hence the composition is as well. Now every non-zero element of $R/\p$ maps to an invertible element (by an injective map), this means that $\text{Frac}(R/\p)$ can be mapped (by an injective map) into $k([\q])$. Hence $m_2 \circ \alpha_1$ factors as $ f_x^\# \circ m_1$. This means $f_x^\# = g_x^\#$ because the same argument holds.
$\Rightarrow$. Assume $f^\#_x = g^\#_x$. Note that the diagram commutes because of the factorizations (note you have the use only upper arrows in the middle or bottom arrows since we don't know yet if the arrows are the same!). Take $r \in R/\p$. Now we see that $f_x^\# \circ m_1(r)$ can be seen as an element of $S/\q$, because the diagram commutes. So if we restrict the map $f_x^\#$ to $R/\p$, we just get the map $\alpha_1$ (codomain is correct). Because $f^\#_x = g^\#_x$, it follows $\alpha_1=\alpha_2$.
We have $\alpha_1 \circ \pi_\p = \pi_\q \circ \varphi $ because the diagram commutes. In the same manner we have $ \alpha_2 \circ \pi_\p = \pi_\q \circ \psi$. Now from $\alpha_1 = \alpha_2$ follows $\pi_\q \circ \varphi = \pi_\q \circ \psi$.
