In Atiyah Macdonald, an A-algebra is defined as a ring B together with a ring homomorphism $f:A\to B$ that induces an A-module structure. Given two A-algebras $f:A\to B$ and $g:A\to C$, an A-algebra homomorphism is defined as a map $h:B\to C$ that is a both a ring homomorphism and an A-linear map.
The book then goes on to say that the map $h$ is an A-algebra homomorphism iff $g=h\circ f$, and this is where I'm running into trouble.
Suppose $g=h\circ f$. I would need to show in particular that $h(b_1 + b_2) = h(b_1) + h(b_2), \forall b_1,b_2 \in B$. If $b_1,b_2 \in Im(f)$, then by letting $b_1 = f(a_1)$ and $b_2 = f(a_2)$ for $a_1, a_2 \in A$ I can proceed as $h(b_1 + b_2) = h(f(a_1) + f(a_2)) = h(f(a_1 + a_2)) = g(a_1 + a_2) = g(a_1) + g(a_2) = h(f(a_1)) + h(f(a_2)) = h(b_1) + h(b_2)$. This would be sufficient if $f$ was surjective, but I don't understand how to proceed in general. Any help would be much appreciated - thanks in advance!