How to find the electric field of an infinite charged sheet using Gauss’s Law? If I have an infinite plane charged sheet with a uniform charge density $\sigma$ and I want to know the electric field at a point $P$ at a distance $\vec r$ away from the sheet, how would I do that?

I approach it like this knowing that this is completely wrong:
I take that point $P$ and draw a Gaussian surface (a sphere in the image) that passes through that point. And since the charge enclosed by the surface is zero, I conclude that the net flux $\phi_E$ through this surface is also zero. And since the net flux $\phi_E$ is zero, the field $\vec E$ is also zero.
Which I know is wrong but I don’t know why?
 A: Gauss' law is always true but not always useful; your example falls in the latter category.  To infer the value of $\vec E$ from $\oint \vec E\cdot d\vec S$ you need a surface on which $\vert \vec E\vert $ is constant so that
$$
\oint \vec E\cdot d\vec S= 
\oint \vert \vec E\vert \, dS = \vert \vec E\vert 
\oint dS = \vert \vec E\vert S \, . \tag{1}
$$
$\vec E$ is not constant on your sphere, meaning you cannot use (1) and pull $\vert \vec E\vert$ out of the integral and recover $\vert\vec E\vert$ through
$$
\vert \vec E\vert = \frac{q_{encl}}{4\pi\epsilon_0 S}\, .
$$
In your specific example, this is why $\oint \vec E\cdot d\vec S=0$ even though $\vert \vec E\vert$ is never $0$ at any point on your Gaussian surface.  The $0$ results from the geometry of $\vec E\cdot d\vec S$ everywhere on the sphere rather than $\vert \vec E\vert=0$.
To proceed you need to use a Gaussian pillbox with sides perpendicular to your sheet because,  by symmetry, the field must also be perpendicular to your sheet. Thus $\vec E\cdot d\vec S$ for all sides of the pillbox is easy to compute. If your pillbox passes through the sheet, it will enclose non-zero charge and, using simple geometry, one easily shows that the flux through the back cap will add to the flux through the front cap and you can recover the usual result.
A: When using Gauss's theorem , you should pay attention that:
1-The Gaussian surface must be chosen in a way that the electric field passing through every point on the surface has the same magnitude and direction as the unit vectors of your coordinates. Therefore I suggest you choose a cube or a cylinder as your Gaussian surface.  Otherwise, it can be difficult to solve the integral .
2- You should note that the Gaussian surface should include the charged plane as well as the given point .
3-You can have Electric field inside a Gaussian surface and zero flux at the same time . Like a point charge placed at the center of a sphere .
