commutative ring and $k(x)$ be a fixed polynomial in $R[x]$ prove there is a unique homomorphism I want to prove following statement. 
Let $R$ be a commutative ring and $k(x)$ be a fixed polynomial in $R[x]$. 
Prove that there exists a unique homomorphism $\phi: R[x] \rightarrow R[x]$ 
such that 
$\phi(r) = r$ for all $r \in R$ and $\phi(x) = k(x)$
 A: You can prove a much more general statement that will avoid confusion  for the specific case. The proof is no harder.

Theorem. Let $\varphi\colon R\to S$ be a homomorphism of commutative rings and let $b\in S$. Then there exists a unique ring homomorphism $\varphi_b\colon R[x]\to S$ such that
  
  
*
  
*$\varphi_b(r)=\varphi(r)$ for all $r\in R$
  
*$\varphi_b(x)=b$
  

Uniqueness is obvious, because, by requirement,
\begin{align}
\varphi_b(a_0+a_1x+\dots+a_nx^n)
&=\varphi_b(a_0)+\varphi_b(a_1)\varphi_b(x)+\dots
  +\varphi_b(a_n)\varphi_b(x^n) \\[6px]
&=\varphi(a_0)+\varphi(a_1)b+\dots+\varphi(a_n)b^n
\end{align}
Existence is just showing that defining
$$
\varphi_b(a_0+a_1x+\dots+a_nx^n)=
\varphi(a_0)+\varphi(a_1)b+\dots+\varphi(a_n)b^n
$$
indeed yields a ring homomorphism.
Your case is when $S=R[x]$, $\varphi$ is the embedding of $R$ into $R[x]$ and $b=k(x)$.
A: By repeatedly applying the definition of a ring homomorphism, we see that any such homomorphism $\phi$ must satisfy
$$
\phi\left(\sum_{i=0}^na_ix^i\right)=\sum_{i=0}^na_ik(x)^i,\qquad a_i\in R.
$$
This uniquely determines $\phi$ as a function on $R[X]$.
To establish existence, it suffices to verify that the function given above is, in fact, a ring homomorphism. For any polynomial $p(x)$ we have that $\phi(p(x))=p(k(x))$. Thus
$$
\phi(r\cdot p(x))=r\cdot p(k(x))=r\cdot \phi(p(x)),\qquad \forall r\in R,
$$
and
$$
\phi(p(x)+q(x))=p(k(x))+q(k(x))=\phi(p(x))+\phi(q(x)),\qquad \forall p(x),q(x)\in R[X].
$$
