define $h(x+I)=\phi(x) + J, \ \forall x \in R.$ this map is well-defined because $\phi(I) \subseteq J.$ it's a homomorphism because $\phi$ is a homomorphism and finally $hf(x)=h(x+I)=\phi(x) + J=g\phi(x), \ \forall x \in R.$