ESP12F webserver problems with insert an button

Hello all.
I have an problem with the code of mine ESP12F
Ihave an code that is working (without an button)

tis is my working code:

/*********
Wifi for screens
*********/

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>

MDNSResponder mdns;

// Replace with your network credentials
const char* ssid = "XXXXXXX";
const char* password = "XXXXXXX";

// Update these with values suitable for your network.
IPAddress ip(192,168,192,128);  //Node static IP
IPAddress gateway(192,168,192,1);
IPAddress subnet(255,255,255,0); 

ESP8266WebServer server(80);

String webPage = "";

int gpio4_pin = 4; // screen 1 OPEN
int gpio5_pin = 5; // screen 1 close
int gpio12_pin = 12; // screen 2 OPEN
int gpio13_pin = 13; // screen 2 close

void setup(void){
  webPage += "<p>Socket #1 <a href=\"socket1On\"><button>ON</button></a>&nbsp;<a href=\"socket1Stop\"><button>STOP</button></a>&nbsp;<a href=\"socket1Off\"><button>OFF</button></a></p>";
  webPage += "<p>Socket #2 <a href=\"socket2On\"><button>ON</button></a>&nbsp;<a href=\"socket2Stop\"><button>STOP</button></a>&nbsp;<a href=\"socket2Off\"><button>OFF</button></a></p>";
  
  // preparing GPIOs
  pinMode(gpio4_pin, OUTPUT);
  digitalWrite(gpio4_pin, LOW);
  pinMode(gpio5_pin, OUTPUT);
  digitalWrite(gpio5_pin, LOW);
  pinMode(gpio12_pin, OUTPUT);
  digitalWrite(gpio12_pin, LOW);
  pinMode(gpio13_pin, OUTPUT);
  digitalWrite(gpio13_pin, LOW);
  
  delay(1000);
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  WiFi.config(ip, gateway, subnet);

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
  
  if (mdns.begin("esp8266", WiFi.localIP())) {
    Serial.println("MDNS responder started");
  }
  
  server.on("/", [](){
    server.send(200, "text/html", webPage);
  });

  //screen control 1//
  //screen OPEN
  server.on("/socket1On", [](){
    server.send(200, "text/html", webPage);
    digitalWrite(gpio5_pin, LOW);
    delay(1000); 
    digitalWrite(gpio4_pin, HIGH);
    delay(1000);
  });
  //screen closed
  server.on("/socket1Off", [](){
    server.send(200, "text/html", webPage);
    digitalWrite(gpio4_pin, LOW);
    delay(1000); 
    digitalWrite(gpio5_pin, HIGH);
    delay(1000); 
  });
  //screen STOP
    server.on("/socket1Stop", [](){
    server.send(200, "text/html", webPage);
    digitalWrite(gpio4_pin, LOW);
    digitalWrite(gpio5_pin, LOW);
    delay(1000); 
  });


  //screen controll 2//
  //screen OPEN
  server.on("/socket2On", [](){
    server.send(200, "text/html", webPage);
    digitalWrite(gpio13_pin, LOW);
    delay(1000); 
    digitalWrite(gpio12_pin, HIGH);
    delay(1000);
  });
  //screen closed
  server.on("/socket2Off", [](){
    server.send(200, "text/html", webPage);
    digitalWrite(gpio12_pin, LOW);
    delay(1000); 
    digitalWrite(gpio13_pin, HIGH);
    delay(1000); 
  });
  //screen STOP
    server.on("/socket2Stop", [](){
    server.send(200, "text/html", webPage);
    digitalWrite(gpio12_pin, LOW); 
    digitalWrite(gpio13_pin, LOW);
    delay(1000); 
  });
  server.begin();
  Serial.println("HTTP server started");
}
 
void loop(void){
  server.handleClient();
}

now i want to add buttons so that i can turn on and off my output from the webpage and also manual with buttons

this is the code i tried:

/*********
Wifi voor de rolluiken
*********/

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>

MDNSResponder mdns;

// Replace with your network credentials
const char* ssid = "xxxxxxxxx";
const char* password = "xxxxxxxx";

// Update these with values suitable for your network.
IPAddress ip(192,168,192,128);  //Node static IP
IPAddress gateway(192,168,192,1);
IPAddress subnet(255,255,255,0); 

ESP8266WebServer server(80);

String webPage = "";

int gpio4_pin = 4; // screen 1 OPEN
int gpio5_pin = 5; // screen 1 closed
int gpio12_pin = 12; // screen 2 OPEN
int gpio13_pin = 13; // screen 2 closed
const int gpio9_pin = 9; // screen 1 manual open

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup(void){
  webPage += "<p>Socket #1 <a href=\"socket1On\"><button>ON</button></a>&nbsp;<a href=\"socket1Stop\"><button>STOP</button></a>&nbsp;<a href=\"socket1Off\"><button>OFF</button></a></p>";
  webPage += "<p>Socket #2 <a href=\"socket2On\"><button>ON</button></a>&nbsp;<a href=\"socket2Stop\"><button>STOP</button></a>&nbsp;<a href=\"socket2Off\"><button>OFF</button></a></p>";
  
  // preparing GPIOs
  pinMode(gpio4_pin, OUTPUT);
  digitalWrite(gpio4_pin, LOW);
  pinMode(gpio5_pin, OUTPUT);
  digitalWrite(gpio5_pin, LOW);
  pinMode(gpio12_pin, OUTPUT);
  digitalWrite(gpio12_pin, LOW);
  pinMode(gpio13_pin, OUTPUT);
  digitalWrite(gpio13_pin, LOW);

  //screen manual
   pinMode(gpio9_pin, INPUT);
  
  delay(1000);
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  WiFi.config(ip, gateway, subnet);

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
  
  if (mdns.begin("esp8266", WiFi.localIP())) {
    Serial.println("MDNS responder started");
  }
  
  server.on("/", [](){
    server.send(200, "text/html", webPage);
  });

  //screen control 1//
  //screen OPEN
  server.on("/socket1On", [](){
    server.send(200, "text/html", webPage);
    digitalWrite(gpio5_pin, LOW);
    delay(1000); 
    digitalWrite(gpio4_pin, HIGH);
    delay(1000);
  });
  //screen closed
  server.on("/socket1Off", [](){
    server.send(200, "text/html", webPage);
    digitalWrite(gpio4_pin, LOW);
    delay(1000); 
    digitalWrite(gpio5_pin, HIGH);
    delay(1000); 
  });
  //screen STOP
    server.on("/socket1Stop", [](){
    server.send(200, "text/html", webPage);
    digitalWrite(gpio4_pin, LOW);
    digitalWrite(gpio5_pin, LOW);
    delay(1000); 
  });


  //screen control 2//
  //screen OPEN
  server.on("/socket2On", [](){
    server.send(200, "text/html", webPage);
    digitalWrite(gpio13_pin, LOW);
    delay(1000); 
    digitalWrite(gpio12_pin, HIGH);
    delay(1000);
  });
  //screen closed
  server.on("/socket2Off", [](){
    server.send(200, "text/html", webPage);
    digitalWrite(gpio12_pin, LOW);
    delay(1000); 
    digitalWrite(gpio13_pin, HIGH);
    delay(1000); 
  });
  //screen STOP
    server.on("/socket2Stop", [](){
    server.send(200, "text/html", webPage);
    digitalWrite(gpio12_pin, LOW); 
    digitalWrite(gpio13_pin, LOW);
    delay(1000); 
  });
  server.begin();
  Serial.println("HTTP server started");
}
 
void loop(void){
  server.handleClient();
{
  // read the state of the pushbutton value:
  buttonState = digitalRead(gpio9_pin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
    // turn LED5 on AND4 OFF:
    digitalWrite(gpio5_pin, HIGH);
    digitalWrite(gpio4_pin, LOW);
  }
}
}

this is what i triet to add:

const int gpio9_pin = 9; // screen 1 manual(with button) open

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status
//manual button
   pinMode(gpio9_pin, INPUT);
{
  // read the state of the pushbutton value:
  buttonState = digitalRead(gpio9_pin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
    // turn pin5 on AND4 OFF:
    digitalWrite(gpio5_pin, HIGH);
    digitalWrite(gpio4_pin, LOW);
  }
}

what i want is:

this code is an wifi webserver that can control 4 outputs to open and close 2 screens.
each screen needs 2 outputs 1 high and 1 low for open.
1 open and 1 high for close.
and 2 low for stop.

now i want to first one butten if it worksi want to add 4 buttens to open and close the screens.
so the buttons needs to de the same as the button on de webserver (1 output low and 1 high)

i hope that someone can help me

thanx

this is the code i tried:

And we're supposed to guess what it actually does, what you wanted it to do, and how those differ? I hate guessing games. I'll pass.

it is a control for two shutters.
they can only be controlled with my WiFi module in the first code.
Now I want to open and close the shutters also with buttons.

so i tried to modify my first code and add an button.
but that does not work and I can not find the problem

but that does not work

Bummer. If you want help, you need to do better than that. Go back and read reply #1 again.

Which IDE version are you using?
What needs to happen if button is not pressed?
How have you wired the button?