Assume that $f,g\in k[x]$ and $(f)=(g)$. Is it true that $\deg(f) = \deg(g)$? What about the converse? Let $\deg(f)=m$, $\deg(g)=n$. Assume $m>n$. Besides, we have $f(x)p(x)=g(x)$ for some $p(x)\in k[x]$.
$\deg(g)=\deg(f)+\deg(p)\implies n=m+\deg(p)\implies \deg(p)=n-m<0$. Contradiction, because degree of a polynomial cannot be negative by definition. Therefore, $m=n.$
Now, converse? Assume $f(x)=x^3$ and $g(x)=x^3+x^2+x+1$, if $f$ generates $g$ then $g=fp$ for some $p \in k[x]$ meaning that $f$ divides $g$. Let's check it.
$$x^3+x^2+x+1=(x^3)(1) + (x^2+x+1)$$
$$(x^3)=(x^2+x+1)(x)+(-x^2-x)$$
$$(x^2+x+1)=(-x^2-x)(-1) + 1$$
So, they are relatively prime, which contradicts $g=fp$.
What do you think?
 A: Consider the ideals $(x)$ and $(x+1)$,
clearly $x+1$ does not belong to $(x)$ as $0$ is a root of every element of $(x)$.
Hence a contradiction.
Your example also works fine.
A: For the counterexample you can consider $x^2$ and $x^2-3$ in $\mathbb{Q}[x]$; the ideals they generate are not the same because $(x^2)$ is not prime, whereas $(x^2-3)$ is maximal. But $(x)$ and $(x-1)$ are good as well.
For the other direction: suppose $(f)=(g)$; then $g(x)=p(x)f(x)$ and $f(x)=q(x)g(x)$, so in particular
$$
f(x)=p(x)q(x)f(x)
$$
and therefore
$$
f(x)(1-p(x)q(x))=0
$$
If you find $p(x)$ and $q(x)$ such that $p(x)q(x)=1$, then surely $f(x)$ and $p(x)f(x)$ generate the same ideal.
Now, let the coefficient ring $R$ be $\mathbb{Z}/4\mathbb{Z}$. Then the polynomial $1+2x$ has the property that $(1+2x)^2=1+4x+4x^2=1$. Thus, for instance, the polynomials $x$ and $x(1+2x)=x+2x^2$ generate the same ideal but their degrees differ.
This does not happen if the coefficient ring is a domain. Indeed, in this case, the degree of the product is the same as the sum of the degrees of the factors. Thus, from
$$
\deg g=\deg p+\deg f\qquad
\deg f=\deg q+\deg g
$$
we obtain $\deg p+\deg q=0$ and therefore $\deg p=\deg q=0$. The special case when $g$ is the zero polynomial is easy to cope with.
A: The converse is wrong. For this, consider the ideals $(x)$ and $(x-1)$. 
The test on equality of ideals can be conducted by using Groebner bases. Use the membership test and test for inclusion both ways.
