''Homomorphism'' of rings Let $R$ and $R'$ rings,  $\phi$ a homomorphism of $R$ to $R'$ such that


*

*$\phi(x+y)=\phi(x)+\phi(y), \quad \forall x,y \in R$.

*$\phi(xy)=\phi(x)\phi(y) \quad or \quad \phi(xy)=\phi(y)\phi(x) \quad \forall x,y \in R.$
Then $\phi(xy)=\phi(x)\phi(y) \,\, \forall x,y \in R$ $\textbf{or}$ $\,\, \phi(xy)=\phi(y)\phi(x) \,\, \forall x,y \in R.$
I tried show that for $a$ fixed, $R_a= \{x\in R : \phi(xa)=\phi(x)\phi(a) \}$ and  $L_a= \{x\in R : \phi(ax)=\phi(a)\phi(x) \}$ are such that $R_a \cap L_a = \{0,1,a\}=T$ and if $y\notin T$ then ($y\in R_a \wedge y\notin L_a$) or ($y\notin R_a \wedge y\in L_a$), 
but i couldn't generalize.
 A: Without loss of generality, if for any $x\in R$ then $\phi(xy)=\phi(x)\phi(y) \; \forall y\in R$, we are done. Otherwise, there exists $x\in R$ such that $\phi(xy)=\phi(x)\phi(y) \ne \phi(y)\phi(x)$ and $\phi(xz)=\phi(z)\phi(x) \ne \phi(x)\phi(z)$ for some $y,z\in R$. 
Hint: Consider $\phi(x(y+z))$.
If you are still stuck, here's the proof:

Consider $\phi(x(y+z))= \phi(xy)+\phi(xz)=\phi(x)\phi(y)+\phi(z)\phi(x)$.If $\phi(x(y+z))=\phi(x)\phi(y+z)=\phi(x)\phi(y)+\phi(x)\phi(z)$ then this follows $\phi(x)\phi(z)=\phi(z)\phi(x)$, a contradiction. If $\phi(x(y+z))=\phi(y+z)\phi(x)=\phi(y)\phi(x)+\phi(z)\phi(x)$ then this follows $\phi(y)\phi(x)=\phi(x)\phi(y)$, a contradiction. Thus, we must have either $\phi(xy)=\phi(x)\phi(y)$ for all $x,y\in R$ or $\phi(xy)=\phi(y)\phi(x)$ for all $x,y\in R$. 

A: Assume there are $x, y$ such that $\phi(xy) = \phi(x)\phi(y) \neq \phi(y)\phi(x)$ (otherwise $\phi(xy) = \phi(y)\phi(x)$ always and we are done).
Take some $z$.
By $(1)$, $\phi(x(y + z)) = \phi(x)\phi(y) + \phi(xz)$.
By $(2)$, either $\phi(x(y + z)) = \phi(x)\phi(y) + \phi(x)\phi(z)$ or $\phi(x(y + z)) = \phi(y)\phi(x) + \phi(z)\phi(x)$.
In the first case we have $\phi(x)\phi(y) + \phi(xz) = \phi(x)\phi(y) + \phi(x)\phi(z)$, so $\phi(xz) = \phi(x)\phi(z)$.
In the second case we have $\phi(x)\phi(y) + \phi(xz) = \phi(y)\phi(x) + \phi(z)\phi(x)$. But as $\phi(x)\phi(y) \neq \phi(y)\phi(x)$, we necessary have $\phi(xz) \neq \phi(z)\phi(x)$, so again $\phi(xz) = \phi(x)\phi(z)$.
Similarly for any $z$ we have $\phi(z y) = \phi(z)\phi(y)$.
Next, $\phi((x + y)(x + y)) = \phi(x + y)\phi(x + y) = \phi(x)\phi(x) + \phi(x)\phi(y) + \phi(y)\phi(x) + \phi(y)\phi(y)$ and also $\phi((x + y)(x + y)) = \phi(xx + xy + yx + yy)$, so $\phi(yx) = \phi(y)\phi(x)$.
Now take some $a$ and $b$. We have $\phi(ab) = \phi((a + x - x)b) = \phi((a - x)b) + \phi(x)\phi(b)$. If $\phi((a - x)b) = \phi(a - x)\phi(b)$, then $\phi(ab) = \phi(a) \phi(b)$. Otherwise we have $\phi(ab) = \phi(b)\phi(a) - \phi(b)\phi(x) + \phi(x)\phi(b)$. If $\phi(x)\phi(b) \neq \phi(b)\phi(x)$, then we again have $\phi(ab) \neq \phi(b)\phi(a)$, so $\phi(ab) = \phi(a)\phi(b)$.
So if $\phi(ab) \neq \phi(a)\phi(b)$, we necessary have $\phi(x)\phi(b) = \phi(b)\phi(x)$. Similarly we have $\phi(x)\phi(a) = \phi(a)\phi(x)$ and the same for $y$.
Now $\phi((x + a)(y + b)) = \phi(xy + xb + ay + ab) = \phi(x)\phi(y) + \phi(x)\phi(b) + \phi(a)\phi(y) + \phi(ab)$.
At the other hand, $\phi((x + a)(y + b)) = \phi(x + a)\phi(y + b)$ or $\phi((x + a)(y + b)) = \phi(y + b)\phi(x + a)$.
In the first case, we have $\phi(x)\phi(y) + \phi(x)\phi(b) + \phi(a)\phi(y) + \phi(ab) = \phi(x)\phi(y)+\phi(x)\phi(b)+\phi(a)\phi(y)+\phi(a)\phi(b)$ so $\phi(ab) = \phi(a)\phi(b)$.
In the second,  $\phi(x)\phi(y) + \phi(x)\phi(b) + \phi(a)\phi(y) + \phi(ab) = \phi(y)\phi(x) + \phi(b)\phi(x) + \phi(y)\phi(a) + \phi(b)\phi(a) =\\ \phi(y)\phi(x) + \phi(x)\phi(b) + \phi(a)\phi(y) + \phi(b)\phi(a)$. As $\phi(x)\phi(y) \neq \phi(y)\phi(x)$, we again have $\phi(ab) \neq \phi(b)\phi(a)$, so $\phi(ab) = \phi(a)\phi(b)$.
Thus, for any $a$ and $b$ we have $\phi(ab) = \phi(a)\phi(b)$. QED.
