Prove that an inner product can be introduced in $E$ such that $\phi$ becomes an orthogonal projection if and only if $\phi^2 = \phi$ In the book of Linear Algebra by Greub, at page 229 question 4, it is asked that

Consider linear transformation $\phi$ of a real linear space $E$.
  Prove that an inner product can be introduced in $E$ such that $\phi$
  becomes an orthogonal projection if and only if $\phi^2 = \phi$

We already know that if $\phi$ has n linearly independent eigenvector, we can define an inner product in $E$ s.t  $\phi$ is self-adjoint.
To show  $\phi^2 = \phi \Rightarrow \phi $ is orthogonal projection, first I need to know that $\phi$ has n linearly independent eigenvectors, but $\phi^2 = \phi$ only says that $\phi$ is stable under $Im \phi$, and does not say anything about the eigenvectors of $\phi$, so how can we prove this part ?
 A: Since $\phi^2 - \phi = 0$, the eigenvectors are at most the roots of the polynomial $z^2 - z = 0$, i.e. $0$ and $1$.
Because this polynomial is square-free, it is the minimal polynomial, and hence $\phi$ is diagonalisable. Otherwise, to show that there is a basis of eigenvalues, we can show the generalised eigenspaces coincide with the eigenspaces.
First, note that since $\phi = \phi^2$, we have $\operatorname{ker} \phi = \operatorname{ker}(\phi^2)$, which means that the eigenspace corresponding to $0$ is the generalised eigenspace.
Second, note that
$$(\phi - I)^2 = \phi^2 - 2\phi + I = \phi - 2\phi + I = I - \phi,$$
hence
$$\operatorname{ker}((\phi - I)^2) = \operatorname{ker}(I - \phi) = \operatorname{ker}(\phi - I).$$
Similarly, the eigenspace corresponding to $1$ is the generalised eigenspace.
Since $0$ and $1$ are the only possible eigenvalues, this makes $\phi$ diagonalisable.
A: We don't have to mention eigenvalues or eigenvectors.
Let $$ U:={\rm im}(\phi)\subset E,\quad V:={\rm ker}(\phi)\subset E\ .$$ Then ${\rm dim}(U)+{\rm dim}(V)={\rm dim}(E)$; furthermore $U\cap V=\{0\}$. (To prove the latter consider an $x\in U\cap V$. Then there is a $y\in E$ with $x=\phi(y)$, hence $0=\phi(x)=\phi^2(y)=\phi(y)=x$.)
It follows that $E=U\oplus V$. Choose a basis $(e_1,\ldots, e_r)$ of $U$ and a basis $(e_{r+1},\ldots, e_n)$ of $V$. Then $(e_1,\ldots, e_n)$ is a basis of $E$. Declare this basis orthonormal. 
A: Just want to give a (relatively) easier explanation for my question:
Consider $\phi - i$.Since 
$$\phi (\phi - i) = \phi^2 - \phi = 0 $$
we have
$$(\phi -i)(v) \in Ker(\phi) \quad \forall v \in E.$$
Now, if we restrict $(\phi -i)$ to $Im (\phi)$, that is 
$$(\phi -i)(\phi(v)) = \phi^2 - \phi = 0,$$
so 
$$\phi (v) = i(v) \quad \forall v \in Im(\phi).$$
Moreover, we do now that, 
$$E = Ker (\phi) \oplus Im (\phi).$$
In fact, given $a \in E$, 
$$\phi (a) = b \in Im(\phi) \Rightarrow \phi^2 (a) = \phi(b) = \phi(a) \\
\Rightarrow \phi (b-a) \in Ker(\phi),$$
hence $\exists h \in Ker(\phi)$ s.t $$h = b-a \Rightarrow a = h + b$$, which proves the result.
Now, since $\phi|_{Ker(\phi)} = 0_E$ and $\phi|_{Im\phi} = i_E$, $\phi$ clearly has $n$ linearly independent eigenvectors corresponding to the eigenvalues $0$ and $1$.
Now, introduce an inner product in $E$ s.t these eigenvectos are orthogonal, and we are done.
A: Just to increase the diversity of the answers:
Observe that $\phi$ make the polynomial 
$$p(x) = x^2 - x = x(x-1)$$
zero, so the minimal polynomial of $\phi$, $m_\phi$ has to divide $p$.
This implies that either $m_\phi (x) = x$, or $m_\phi (x) = x-1$, or $m_\phi (x) = x(x-1)$.
In the first case, $\phi$ has to be the zero map, so the result is trivial.
In the second case, $\phi = i$, again the result is trivial.
In the third case, since the minimal polynomial of $\phi$ contains distinct linear factors of power $1$ (moreover, minimal and characteristic polynomial have the same roots), by the theorem, $\phi$ is diagonalizable, hence have $n$ linearly independent eigenvectors corresponding to the eigenvalues $0$ and $1$.
