This is exercise $10$ from chapter $1$, section $1$ of the text
Kaplansky${\,-\,}$Commutative Rings, Rev Ed (1974)
Fleshing out the author's extended hint, we can argue as follows . . .
Let $U$ be a non-principal ideal of $R$ which is maximal among all non-principal ideals of $R$.
Suppose $U$ is not prime.
Our goal is to derive a contradiction.
Let $ab \in U$, with $a,b\notin U$.
Then $(U,a) = (c)$, for some $c\in R$.
Let $V=\{x\in R\mid cx \in U\}$.
Clearly we have $U \subseteq V$.
Since $(U,a)=(c)$, we have $u+ra=c$, for some $u\in U$ and some $r\in R$.
\begin{align*}
\text{Then}\;\;&u+ra=c
\qquad\qquad\qquad\qquad\qquad\qquad\qquad\;\;\;
\\[4pt]
\implies\;&b(u+ra)=bc\\[4pt]
\implies\;&bu+r(ab)=bc\\[4pt]
\implies\;&bc\in U\qquad\text{[since $ab\in U$]}\\[4pt]
\implies\;&b\in V
\end{align*}
Since $U \subseteq V$, and $b \in V\setminus U$, we have the proper inclusion $U\subset V$, hence $V=(d)$ for some $d\in R$.
Now let $u$ be an arbitrary element of $U$.
Since $U\subset (U,a)=(c)$, we get $u=cy$, for some $y\in R$.
\begin{align*}
\text{Then}\;\;&u=cy\\[4pt]
\implies\;&cy \in U\\[4pt]
\implies\;&y\in V&&\text{[by definition of $V$]}\\[4pt]
\implies\;&y = dz,\;\text{for some}\;z\in R&&\text{[since $V=(d)$]}\\[4pt]
\implies\;&u = c(dz)\\[4pt]
\implies\;&u \in (cd)\\[4pt]
\end{align*}
Thus, $U\subseteq (cd)$.
Also, since $d\in V$, then by definition of $V$, we get $cd\in U$, hence $(cd) \subseteq U$.
But then $U=(cd)$, contrary to the assumption that $U$ is not principal.
It follows that $U$ is prime.