To Find $\int_0^{\pi} \frac{\sin(x)}{1+\sin(x)}$ why the substitution of $\sin(x)=t$ Gives wrong answer? To find out this basic integral
 $$\int_0^{\pi} \frac{\sin(x)}{1+\sin(x)} \,\mathrm{d}x$$
I though of two methods : 
Method 1:
I started by multiplying and dividing by $1-\sin(x)$  and then manipulating it one easily gets -
$$\int_0^{\pi} {(\sec(x)\tan(x) - (\tan(x))^2})\,\mathrm{d}x$$
Which is quite easy to calculate and gives value of $\pi-2$
I do not have any problem with this method , even though it took me some time to solve it.
Method 2 : 
This was first thing I had thought of :
To let $\sin(x)=t$ and then when I tried to change the limits of integral I found that this substitution makes both upper and lower limits as $t=0$ which would give The value of above integral = 0 , according to the property
$\int_a^a f(x)\,\mathrm{d}x = 0$.
But the previous method gives answer of $\pi-2$ then what is wrong with the method 2 . Is that substitution incorrect ? But how and why ?
 A: The sine function is not an injective function over the interval $(0,\pi)$. If you want to apply the substitution $\sin(x)\mapsto z$, you have to break the integration range in halves: this because a valid substitution is given by a diffeomorphism, not just a differentiable map. 
In simple words, you are allowed to state that
$$\int_{a}^{b}f(x)\,dx = \int_{g^{-1}(a)}^{g^{-1}(b)} f(g(s))\,g'(s)\,ds$$
only if $g$ is an injective function over the involved integration range, and $\sin(x)$ is not injective over $(0,\pi)$. Otherwise you would get $\int_{0}^{\pi}\sin(x)\,dx=0$ and that is clearly wrong.
A possible way to go is: since the $\sin(x)$ function is symmetric with respect to the point $x=\pi/2$,
$$ \int_{0}^{\pi}\frac{\sin(x)\,dx}{1+\sin(x)}=2\int_{0}^{\pi/2}\frac{\sin(x)\,dx}{1+\sin(x)}=2\int_{0}^{1}\frac{t\,dt}{(1+t)\sqrt{1-t^2}}.$$
That is correct, even if not the most efficient way for computing such integral. A more efficient way is to set $x=2\arctan\frac{t}{2}$ (aka Weierstrass substitution) to get
$$16\int_{0}^{+\infty}\frac{t\,dt}{(4+t^2)(2+t)^2}$$
that can be tackled through partial fraction decomposition.
A: Method 2 fails since on $[0,\pi]$, $\sin(x)$ is not monotone, so we don't have a good inverse to apply. We need to break the interval into intervals on which $\sin(x)$ is monotone. For example, $\left[0,\frac\pi2\right]$ and $\left[\frac\pi2,\pi\right]$.  In fact, using the substitution $x\mapsto\pi-x$, we get
$$
\int_0^{\pi/2}\frac{\sin(x)}{1+\sin(x)}\,\mathrm{d}x=\int_{\pi/2}^\pi\frac{\sin(x)}{1+\sin(x)}\,\mathrm{d}x
$$
so that
$$
\begin{align}
\int_0^\pi\frac{\sin(x)}{1+\sin(x)}\,\mathrm{d}x
&=2\int_0^{\pi/2}\frac{\sin(x)}{1+\sin(x)}\,\mathrm{d}x\\
&=2\int_0^1\frac{t}{1+t}\,\mathrm{d}\arcsin(t)\\
&=2\int_0^1\frac{t}{1+t}\frac{\mathrm{d}t}{\sqrt{1-t^2}}\\
&=2\int_0^1\left(1-\frac1{1+t}\right)\frac{\mathrm{d}t}{\sqrt{1-t^2}}\\
&=\pi-2\int_0^1\frac1{1+t}\frac{\mathrm{d}t}{\sqrt{1-t^2}}\\
&=\pi-2\left[-\sqrt{\frac{1-t}{1+t}}\,\right]_0^1\\[6pt]
&=\pi-2
\end{align}
$$
A: Hint: set $$t=\tan(x/2)$$ and then we have $$\sin(x)=\frac{2t}{1+t^2}$$ 
A: While the tangent half angle substitution (Weierstrass sub) is a general approach that works, as suggested by Sonnhard, it can be avoided here since you may not be familiar with that tool of integration, so here is another approach by FIRST rewriting and splitting the numerator:
$$\frac{sinx}{1+sinx}=\frac{1+sinx-1}{sinx+1}=1-\frac{1}{1+sinx}$$
The latter can be integrated by multiplying top an bottom by $1-sinx$. It then becomes really easy. As Jack suggested, be a little careful with those limits...Give it try
A: \begin{align}
\frac{\sin x}{1+\sin x}&=1-\frac{1}{1+\sin x}\\
&=1-\frac{1}{\left(\cos \frac x2+\sin \frac x2\right)^2}\\
&=1-\frac{\cos^2 \frac x2+\cos \frac x2 \sin \frac x2+ \sin^2\frac x2-\cos \frac x2 \sin\frac x2}{\left(\cos \frac x2+\sin \frac x2\right)^2}\\
&=1-\frac{\cos \frac x2\left(\cos \frac x2+ \sin \frac x2\right)-2 \sin\frac x2\left(-\frac12\sin\frac x2+\frac12\cos \frac x2 \right)}{\left(\cos \frac x2+\sin \frac x2\right)^2}\\
&=\frac{d}{dx}\left(x-\frac{2\sin \frac x2}{\cos \frac x2+\sin \frac x2}\right)
\end{align}
Hence
\begin{align}
\color{red}{\int_0^{\pi}\frac{\sin x}{1+\sin x}dx=\pi-2}.
\end{align}
