Find flux of $ \vec{F} =<0,0,z>$ through the sphere of radius $a$ centered at the origin.
Using Gauss Divergence Theorem
$$ \nabla \cdot \vec{F} = 1 \\ \therefore \int_S \vec{F}\cdot \hat{n} ~dS= \iiint_R 1 ~dV =\frac{4}{3}\pi a^3 $$
Calculating the surface integral by using sperical co-ordinates $ (\rho, \phi, \theta )$
$$ \hat{n} = \frac{1}{a} <x,y,z> \\ \vec{F} \cdot \hat{n}=\frac{z^2}{a}$$
w.k.t
$$ dS= a^2 \sin(\theta) ~ d\phi d\theta \\ z= a cos(\phi)$$
substituting:
$$\int_s \vec{F}\cdot \hat{n} ~dS = \int_0^{2\pi} \int_0^\pi \frac{a^2 cos^2(\phi)}{a} a^2 \sin(\theta) ~ d\phi d\theta \\ $$
This integral will evaluate to zero, because $sin(\theta)$ will be integrated from $0$ to $2\pi$.
I'm getting two different answers. Where am I going wrong?