Let $G$ be a non-cyclic group of order $p^3$ for an odd prime $p$. Prove that $G \simeq H \rtimes_{\theta}K$, where $H$ is a normal subgroup of $G$ of order $p^2$, $K$ is a subgroup of order $p$, and $\theta : K \to Aut(H)$ is a homomorphism.
I managed to prove that there exists a normal subgroup $H$ of order $p^2$. Then I took some $g \in G-H$. If $g$ is of order $p$, I am done since $G \simeq H \rtimes \langle g \rangle $. But what if all $g \in G - H$ are of order $p^2 $?