Let $R$ be a commutative ring with identity, $I$ an ideal in $R$, $\pi : R \to R/I$ the canonical projection, and let $S$ be some multiplicative subset of $R$. Define $\theta : S^{-1}R \to (\pi(S))^{-1} (R/I)$ by $\theta (r/s) = \pi(r)/\pi(s)$. Prove that $\theta$ is an epimorphism with kernel $S^{-1}I$ and hence induces a ring isomorphism $S^{-1}R/S^{-1}I \simeq (\pi(S))^{-1}(R/S)$.
I have already show that if $S$ is a multiplicative subset, then $\pi(S)$ is a multiplicative subset of $R/I$; and that $\theta$ is a well-defined epimorphism. The only step I am having trouble with is show that $\ker \theta = S^{-1} I$.
If $r/s \in \ker \theta$, then $\frac{r + I}{s+I} = \frac{I}{x + I}$ for every $x \in S$, which is to say there exists an $s_1 \in S$ such that $(s_1 + I)(I (s+I) - (r+I)(x+I)) = I$ or $rs_1 x + I = I$ for every $x \in S$. This in turn implies $rs_1 x \in I$ for every $s \in S$. From my understanding, we need to conclude that $r \in I$. I think that if $S \cap I$ weren't empty, then we would have the zero element $0+I=I$ in some denominators of the elements in $(\pi(S))^{-1}(R/I)$, so that we should assume $S \cap I = \emptyset$. Unfortunately, $I$ isn't necessarily a prime ideal so I cannot conclude that $r \in I$.
I could use a hint.
Since $r s_1 x \in I$ and $s_1, x \in S$, then $$ \frac{r}{s} = \frac{r s_1 x}{s s_1 x} \in S^{-1} I \, . $$
Your mistake is assuming that if $r/s \in S^{-1}I$, then $r \in I$. This need not be the case. For example, let $\newcommand{\Z}{\mathbb{Z}}R = \Z$, $P = 3\Z$, so $S = \Z \setminus 3\Z$, and $I = 6\Z$. Then $$ I_P = S^{-1} I = \left\{\frac{6m}{n} : m,n \in \Z, 3 \nmid n\right\} \, . $$ Since $2 \in S$ then $\frac{3}{1} = \frac{6}{2} \in I_P$, but $3 \notin I$.