ESP8266 first code help

david1234:
this is very strange when it say

it is recommended to avoid using GPIO0, GPIO2

because this is all I have in my the ESP8266......

that comment about not using those GPIO pins is a comment in my code for one of my projects.
I also said, for inputs
It isn't that you can't use those GPIO pins, it is that you must be careful how you use them.
It can create issues if you use them for inputs as the external source can be driving the pin and affect the boot mode.
See the documents I linked to for full details.
In my case I was using a Wemos D1 mini and I had a button connected to GPIO2. Normally that would be ok as the button was a normally open switch so as long as it wasn't pushed while the processor was booting it would be ok.
However, in my case I needed the ability to hold the button down at powerup for a special purpose so I couldn't use GPIO2 for that.

Now I know I need to gnd the GPIO0 for programing
and put GPIO2 as HIGH

but this is all the GPIO I have - so what can I do ?
my GPIO2 is connected to the window\door sensor that sending "1""0"

What specific esp8266 module do you have?
You never said which board you have. There is some slight variation between modules.
But for certain pins you can't drive the pin until after the processor has booted.
After it has booted, it can work as a normal input pin.
You should read the esp8266 documentation and the documentation for your specific board for full details.

I think you should test things methodically and in small steps rather than all at once.
It will make debugging much simpler.
i.e. get the sensor input working using just serial output without using any WiFi.
Once that is working, add in the WiFi & web support.

--- bill