How to integrate this question? Question -

$\int_0^{\frac{\pi}{2}} \frac{dx}{1+\cos^2x}$

I put $\cos x = t$ 

Then $-\sin x\; dx = dt$

But then I am totally confused what to do with $\sin x.$

How to solve this.
Well, when you substitute $t=\cos\left(x\right)$ then we know that:

$$\cos^2\left(x\right)+\sin^2\left(x\right)=t^2+\sin^2\left(x\right)=1\tag1$$

Another way, substitute $\text{u}=\tan\left(x\right)$:

$$\int_0^\frac{\pi}{2}\frac{1}{1+\cos^2\left(x\right)}\space\text{d}x=\int_0^\infty\frac{1}{2+\text{u}^2}\space\text{d}\text{u}\tag2$$

And after that substitute $\text{v}=\frac{\text{u}}{\sqrt{2}}$:

$$\int_0^\infty\frac{1}{2+\text{u}^2}\space\text{d}\text{u}=\frac{1}{\sqrt{2}}\int_0^\infty\frac{1}{1+\text{v}^2}\space\text{d}\text{v}=\frac{1}{\sqrt{2}}\left(\lim_{\text{v}\to\infty}\arctan\left(\text{v}\right)-\arctan\left(0\right)\right)=\frac{\frac{\pi}{2}-0}{\sqrt{2}}\tag3$$
From $\cos x=t$ and $-\sin x\,dx=dt$ you draw 

$$dx=-\frac{dt}{\sin x}=-\frac{dt}{\sqrt{1-t^2}}.$$

Then your integral becomes

$$-\int_1^{0}\frac{dt}{(1+t^2)\sqrt{1-t^2}}$$ which, unfortunately, doesn't look much simpler.