Let $p$ a prime number, $G$ a finite group with order $p^n$ and suppose that $G$ has an only subgroup of order $p$. Then $G$ is cyclic.
Proof:
Let $P$ the unique subgroup of order $p$, and any subgroup of $G$ has order $p^k$ with $k<n$, so $P\leq H$ and is the only subgroup of order $p$ of H.
Consider the next function $\phi:G\rightarrow G$ such that $\phi_(g)=g^p$, clearly $\phi$ is an homomorphism and $ker\phi=P$ because $x\in ker\phi$ implies that $ord(x)=p$ and $\langle{x}\rangle$ is a subgroup of order $p$ contained in $ker\phi$ and this means that $ker\phi-P=\emptyset$. Then we have that:
$$\frac{G}{P}\simeq Im\phi$$so, by the Lagrange's theorem we have $|G|/|P|=\left|Im\phi\right|$ therefore $|G|/|Im\phi|=p$.
We apply induction to the order of $G$ to show that is cyclic.
If $|Im\phi|=1$ then $Im\phi=\{e\}$ so $G=P$ and then $G$ is cyclic, (cuz $P$ are cyclic).
If $Im\phi\ne\{e\}$ then $|Im\phi|=p^{n-1}$ and by the induction hypothesis $Im\phi$ are cyclic. Let $Im\phi=\langle{x}\rangle$ for some $x\in Im\phi$, thus take $g\in G$ such that $\phi(g)=x$ then $g^p=x$.
I understood all this, but the next statement said: "This implies that $[\langle{g}\rangle:Im\phi]=p$" This part is the part that I don't understand.
Then by the third theorem of isomorphism $G/\langle{g}\rangle\simeq\left(G/Im\phi\right)/\left(\langle{g}\rangle/Im\phi\right)$ and therefore $G=\langle{g}\rangle$
The statement is false, and the error in the proof is the claim that "clearly $\phi$ is an homomorphism". But if you restrict to abelian groups, then the statement is true and the proof is essentially correct. From the conclusions that $|\textrm{im}(\phi)| = p^{n-1}$, $\textrm{im}(\phi)=\langle x\rangle$, and $g^p = x$, you obtain that the order of $g$ is $p^n$. Thus the cyclic subgroup generated by $g$ is all of $G$, proving that $G$ is cyclic.