ESP8266 Read data from HTML and send it to INT value

Hi everyone! :slight_smile:

I'm New to arduino so this might seem like a stupid question for you, but how the hell can I insert a value on an HTML page and write it in an int variable?

I've already built the page, here is the code:

                   client.println("Orario 1: <input type='int' name='Hou' id='Hou' size=2 autofocus> hh <input type='int' name='Min' id='Min' size=2 autofocus> mm <input type='int' name='Sec' id='date_ss' size=2 autofocus> ss
");
                   client.println("Orario 2: <input type='int' name='Hou1' id='Hou1' size=2 autofocus> hh <input type='int' name='Min1' id='Min1' size=2 autofocus> mm <input type='int' name='Sec1' id='Sec1' size=2 autofocus> ss
");
                   client.println("Orario 3: <input type='int' name='Hou2' id='Hou2' size=2 autofocus> hh <input type='int' name='Min2' id='Min2' size=2 autofocus> mm <input type='int' name='Sec2' id='Sec2' size=2 autofocus> ss
");
                   client.println("<p><a href=\"Salvato\"><button class=\"button\">Salva</button></a></p>");

When connecting to ESP8266, the web page works fine and the input box appears.
As you can see i've a "Salva" Button.
How do I store the values ‚Äč‚ÄčI place on the web page about variables int Hou Hou 1 etc. inside an INT?

I hope someone can help me
thank you!

You have to create a HTML form (on your page) not just input. read about it here
I use ESPwebserver.h to handle url requests.
The easiest is to let the forma action direct you back towards the same page, and then you can read the form arguments using the .hasArg() and arg() functions. Since the .arg() function returns a String you will have to convert the input to an int using either using .toInt() or with your own function (.toInt() returns 0 for incorrect input, if 0 can be a correct input and if you want incorrect input to be ignored your own function is better)

Deva_Rishi:
You have to create a HTML form (on your page) not just input. read about it here
I use ESPwebserver.h to handle url requests.
The easiest is to let the forma action direct you back towards the same page, and then you can read the form arguments using the .hasArg() and arg() functions. Since the .arg() function returns a String you will have to convert the input to an int using either using .toInt() or with your own function (.toInt() returns 0 for incorrect input, if 0 can be a correct input and if you want incorrect input to be ignored your own function is better)

Thank you! it was exactly what I was looking for! :slight_smile:
But now I have another problem, when I go to use the .hasArg() function it returns me the error:

'class WiFiClient' has no member named 'hasArg'

Actually, client is my WiFiClient: "WiFiClient client = server.available();"

Could it be a problem with libraries? I have updated them with the latest available for the ESP8266, the following libraries are loaded in the program:

#include <ESP8266WebServer.h>
#include <ESP8266WebServerSecure.h>
#include <stdlib.h> used for string conversion
#include <WiFiUdp.h>
#include <WiFiClient.h>
#include <NTPClient.h> For the NTP Time
#include <Servo.h>
#include <DFPlayer.h> DFPlayer mini

The issue is not with the libraries, but with the object you have to create, you are not creating a client(which connects to a page) but a server. check out the HelloServer and AdvancedWebServer examples in Examples\ESP8266WebServer

Deva_Rishi:
The issue is not with the libraries, but with the object you have to create, you are not creating a client(which connects to a page) but a server. check out the HelloServer and AdvancedWebServer examples in Examples\ESP8266WebServer

Thanks again! Seems like it's working, it compiles!
I've also converted strings to INT correctly
But i still can't save the numbers entered on the web page in the strings

From what I see, I have to use the GET function based on the HTTP header but I can not understand how it works...

This is my form:

client.println("<form name=salva action=/Salvaorari method=post>");
                   client.println("Orario 1: <input type='int' name='Ora' id='Ora' size=2 autofocus> : <input type='int' name='Min' id='Min' size=2 autofocus> : <input type='int' name='Sec' id='date_ss' size=2 autofocus>

");
                   client.println("Orario 2: <input type='int' name='Ora1' id='Ora1' size=2 autofocus> : <input type='int' name='Min1' id='Min1' size=2 autofocus> : <input type='int' name='Sec1' id='Sec1' size=2 autofocus>

");
                   client.println("Orario 3: <input type='int' name='Ora2' id='Ora2' size=2 autofocus> : <input type='int' name='Min2' id='Min2' size=2 autofocus> : <input type='int' name='Sec2' id='Sec2' size=2 autofocus>

");
                   client.println("<input type=submit value=Salva>


");
                   client.println("</form>");

Pressing the form button shows the header: ESP8266/Salvaorari on client PC, I've created a trigger on this header but nothing happens...

using the post or the get on an esp doesn't really matter much (just that the arguments will show up in your URL or not) the issue must be in your 'handle' functions that you refer to by

server.on(/Salvaorari, handleFunction);

within setup()
which will call the function

void handleFunction() { }

where you can use the server.hasArg() and server.arg() to extract the arguments and their data.
if you put

server.handleClient()

within loop()

Hi, I did what you said, or at least i Think :slight_smile:

I Declared:

ESP8266WebServer WBServer(80);
int Ora;
int Min;
int Sec;
int Ora1;
int Min1;
int Sec1;
int Ora2;
int Min2;
int Sec2;
String Orastring;
String Minstring;
String Secstring;
String Orastring1;
String Minstring1;
String Secstring1;
String Orastring2;
String Minstring2;
String Secstring2;

VOID SETUP:

WBServer.on("/Gestione/salva", memore);

WEB PAGE AND FORM:

              if (header.indexOf("GET /Gestione") >= 0) {                                                                                              //INIZIO PAGINA GESTIONE
                   client.println("<!DOCTYPE html><html>");
                   client.println("<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">");
                   client.println("<link rel=\"icon\" href=\"data:,\">");
                   client.println("<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}");
                   client.println(".button { background-color: #195B6A; border: none; color: white; padding: 16px 40px;");
                   client.println("text-decoration: none; font-size: 30px; margin: 2px; cursor: pointer;}");
                   client.println(".stato { border: none; color: #195B6A; padding: 16px 40px;");
                   client.println("text-decoration: none; font-size: 30px; margin: 2px; cursor: pointer;}");  
                   client.println("</style></head>");
                   client.println("<body><h1>Althea Italia S.p.A.
Controllo remoto chiusura porte
Potete inserire fino a 3 orari programmati per la chiusura delle porte
</h1>");
                   client.println("<form action=\"/Gestione/salva\" method=\"post\">");
                   client.println("Orario 1: <input type='text' name='Ora' id='Ora' size=2 autofocus> : <input type='text' name='Min' id='Min' size=2 autofocus> : <input type='text' name='Sec' id='date_ss' size=2 autofocus>

");
                   client.println("Orario 2: <input type='text' name='Ora1' id='Ora1' size=2 autofocus> : <input type='text' name='Min1' id='Min1' size=2 autofocus> : <input type='text' name='Sec1' id='Sec1' size=2 autofocus>

");
                   client.println("Orario 3: <input type='text' name='Ora2' id='Ora2' size=2 autofocus> : <input type='text' name='Min2' id='Min2' size=2 autofocus> : <input type='text' name='Sec2' id='Sec2' size=2 autofocus>

");
                   client.println("<input type=submit value=Salva>


");
                   client.println("</form>");
                   client.println("<body><h1>Gli orari attualmente impostati sono:</h1>
");
                   client.println("<p><strong>Orario1: "+ Orastring +":"+ Minstring +":"+ Secstring +" </p></strong>
");
                   client.println("<p><strong>Orario2: "+ Orastring1 +":"+ Minstring1 +":"+ Secstring1 +" </p></strong>
");
                   client.println("<p><strong>Orario3: "+ Orastring2 +":"+ Minstring2 +":"+ Secstring2 +" </p></strong>
");
                   client.println("<p><a href=\"Indietro\"><button class=\"button\">Indietro</button></a></p>");

FORM ACTION (VOID MEMORE):

  if(WBServer.hasArg("Ora")){
  if(WBServer.hasArg("Min")){
  if(WBServer.hasArg("Sec")){
   Orastring = WBServer.arg("Ora");
    Minstring = WBServer.arg("Min");
     Secstring = WBServer.arg("Sec");}}
  int Ora = Orastring.toInt();
  int Min = Minstring.toInt();
  int Sec = Secstring.toInt();}
  if(WBServer.hasArg("Ora1")){
  if(WBServer.hasArg("Min1")){
  if(WBServer.hasArg("Sec1")){
   Orastring1 = WBServer.arg("Ora1");
    Minstring1 = WBServer.arg("Min1");
     Secstring1 = WBServer.arg("Sec1");}}
  int Ora1 = Orastring1.toInt();
  int Min1 = Minstring1.toInt();
  int Sec1 = Secstring1.toInt();}
  if(WBServer.hasArg("Ora2")){
  if(WBServer.hasArg("Min2")){
  if(WBServer.hasArg("Sec2")){
   Orastring2 = WBServer.arg("Ora2");
    Minstring2 = WBServer.arg("Min2");
     Secstring2 = WBServer.arg("Sec2");}}
  int Ora2 = Orastring2.toInt();
  int Min2 = Minstring2.toInt();
  int Sec2 = Secstring2.toInt();}
  delay(25);

But it still doesn't work... :frowning: where is the error?

But it still doesn't work

The code does something. You need to tell us what it ACTUALLY does. If you don't know, add Serial.print() statements until you DO know.

I had to load it into the IDE, but then this showed up straight away :

int Ora = Orastring.toInt();
    int Min = Minstring.toInt();
    int Sec = Secstring.toInt();

eventhough you declared Ora, Min & Sec globally, you re-declared them within void memore() and within the conditional reading of the arguments. try

Ora = Orastring.toInt();
   Min = Minstring.toInt();
   Sec = Secstring.toInt();

I am not saying it's the only error, but this one stood out !

It still does not work :frowning: , I do not understand what I'm doing wrong

This is the FULL code, can I ask you for help?
I'm stuck ... at this point I think there's a problem in the structure of the program

#include <ESP8266WebServer.h>
#include <ESP8266WebServerSecure.h>
#include <stdlib.h>
#include <WiFiUdp.h>
#include <WiFiClient.h>
#include <NTPClient.h>
#include <Servo.h>
#include <DFPlayer.h>

const char* ssid="SSID";                               //SSID WIFI
const char* password="PASSWORD";                       //PASSWORD WIFI
ESP8266WebServer WBServer(80);
WiFiUDP ntpUDP;
NTPClient NTPTime (ntpUDP, "ntp1.inrim.it", 3600);            //SERVER NTP E GMT (3600 +1)
Servo myservo;
const int buttonPIN = D5;
const int piezoPIN = D6;
const int trigPIN = D4;
const int echoPIN = D3;
long durata;
int distanza;
SoftwareSerial mp3Serial(D1, D2);
#define PIN_BUSY D10
WiFiServer server(80);                                        //PORTA SITO WEB
String header;                                                //HEADER SITO WEB
String Door6A1; 
String Door6A2;
String Door6B1;
String Door6B2;
String Door7B1;
String Door7B2;
String Door7A1;
int Ora; 
int Min; 
int Sec;
int Ora1; 
int Min1;
int Sec1;
int Ora2;
int Min2;
int Sec2;
String Orastring; 
String Minstring; 
String Secstring;
String Orastring1; 
String Minstring1; 
String Secstring1;
String Orastring2; 
String Minstring2; 
String Secstring2; 

void setup() 
{
  myservo.write(50);
  Serial.begin(9600);
  delay(250);
  mp3Serial.begin (9600);
  delay(250);
  myservo.attach(13);
  pinMode (buttonPIN, INPUT_PULLUP);
  pinMode (piezoPIN, OUTPUT);
  pinMode (trigPIN, OUTPUT); 
  pinMode (echoPIN, INPUT);
  mp3_set_serial (mp3Serial);  
  delay(1500); 
  mp3_set_volume (28);
  delay(2000);
  WiFi.begin(ssid, password);
  delay(2000);
  server.begin();
  delay(2000);
  WBServer.on("/Gestione/salva", memore);
}

void loop()
{ 
  int buttonState = digitalRead(buttonPIN);                 //LEGGI STATO BOTTONE
  if (buttonState == LOW) {
     azionebottone();
      } else {
        NTPTime.update();                                   //AGGIORNA ORA DA NTP
        oraprogrammata();                                   //LOOP ORARIO PROGRAMMATO
        }    
  WiFiClient client = server.available();
  if (client) {                             
      String currentLine = "";                              // SE CONNESSO A PAGINA WEB CREA STRINGA DA HEADER
      while (client.connected()) {        
        int buttonState = digitalRead(buttonPIN);           //LEGGI STATO BOTTONE CON PAGINA WEB AVVIATA
        if (buttonState == LOW) {
          azionebottone();}
          else {
          NTPTime.update();                                 //AGGIORNA ORA DA NTP
          oraprogrammata();}                                //LOOP ORARIO PROGRAMMATO                                
          if (client.available()) {                         //SE UN CLIENT E' CONNESSO
            char c = client.read();             
            header += c;                                    //LEGGE PAGINA DA CLIENT E SCRIVE IN CHAR C
            if (c == '\n') {                                // SE IL BYTE HEADER E' UN NUOVO CARATTERE
              if (currentLine.length() == 0) {

            //INIZIO AZIONI SULLE PORTE DA WEB
              if (header.indexOf("GET /6A1/chiudi") >= 0) {
                  azionebottone();}

              if (header.indexOf("GET /6A2/chiudi") >= 0) {
                  azionebottone();}            

              if (header.indexOf("GET /6B1/chiudi") >= 0) {
                  azionebottone();}

              if (header.indexOf("GET /6B2/chiudi") >= 0) {
                  azionebottone();}

              if (header.indexOf("GET /7B1/chiudi") >= 0) {
                  azionebottone();}

              if (header.indexOf("GET /7B2/chiudi") >= 0) {
                  azionebottone();}

              if (header.indexOf("GET /7A1/chiudi") >= 0) {
                  azionebottone();}
if (header.indexOf("GET /Gestione") >= 0) {                                                                                              //INIZIO PAGINA GESTIONE
                   client.println("<!DOCTYPE html><html>");
                   client.println("<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">");
                   client.println("<link rel=\"icon\" href=\"data:,\">");
                   client.println("<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}");
                   client.println(".button { background-color: #195B6A; border: none; color: white; padding: 16px 40px;");
                   client.println("text-decoration: none; font-size: 30px; margin: 2px; cursor: pointer;}");
                   client.println(".stato { border: none; color: #195B6A; padding: 16px 40px;");
                   client.println("text-decoration: none; font-size: 30px; margin: 2px; cursor: pointer;}");  
                   client.println("</style></head>");
                   client.println("<body><h1>Althea Italia S.p.A.
Controllo remoto chiusura porte
Potete inserire fino a 3 orari programmati per la chiusura delle porte
</h1>");
                   client.println("<form action=\"/Gestione/salva\" method=\"post\">");
                   client.println("Orario 1: <input type='text' name='Ora' id='Ora' size=2 autofocus> : <input type='text' name='Min' id='Min' size=2 autofocus> : <input type='text' name='Sec' id='date_ss' size=2 autofocus>

");
                   client.println("Orario 2: <input type='text' name='Ora1' id='Ora1' size=2 autofocus> : <input type='text' name='Min1' id='Min1' size=2 autofocus> : <input type='text' name='Sec1' id='Sec1' size=2 autofocus>

");
                   client.println("Orario 3: <input type='text' name='Ora2' id='Ora2' size=2 autofocus> : <input type='text' name='Min2' id='Min2' size=2 autofocus> : <input type='text' name='Sec2' id='Sec2' size=2 autofocus>

");
                   client.println("<input type=submit value=Salva>


");
                   client.println("</form>");
                   client.println("<body><h1>Gli orari attualmente impostati sono:</h1>
");
                   client.println("<p><strong>Orario1: "+ Orastring +":"+ Minstring +":"+ Secstring +" </p></strong>
");
                   client.println("<p><strong>Orario2: "+ Orastring1 +":"+ Minstring1 +":"+ Secstring1 +" </p></strong>
");
                   client.println("<p><strong>Orario3: "+ Orastring2 +":"+ Minstring2 +":"+ Secstring2 +" </p></strong>
");
                   client.println("<p><a href=\"Indietro\"><button class=\"button\">Indietro</button></a></p>"); 
                   break;                                                                                                                              //FINE PAGINA GESTIONE                   
              } else {
            //FINE AZIONI SULLE PORTE DA WEB          
 sonar();                                                                                                                                              //MISURA DISTANZA PORTA 1 CICLO
                                                                                                                                                       //INIZIO PAGINA HOME
 client.println("<!DOCTYPE html><html>");
 client.println("<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">");
 client.println("<link rel=\"icon\" href=\"data:,\">");
 client.println("<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}");
 client.println(".button { background-color: #195B6A; border: none; color: white; padding: 16px 40px;");
 client.println("text-decoration: none; font-size: 30px; margin: 2px; cursor: pointer;}");
 client.println(".stato { border: none; color: #195B6A; padding: 16px 40px;");
 client.println("text-decoration: none; font-size: 30px; margin: 2px; cursor: pointer;}");  
 client.println("</style></head>");
 client.println("<body><h1>Althea Italia S.p.A.
Controllo remoto chiusura porte
</h1>");
 client.println("<p><a href=\"/6A1/chiudi\"><button class=\"button\">CHIUDI PORTA 6A1</button></a><stato class=\"stato\">" + Door6A1 + "</p>");
 client.println("<p><a href=\"/6A2/chiudi\"><button class=\"button\">CHIUDI PORTA 6A2</button></a><stato class=\"stato\">" + Door6A2 + "</p>");
 client.println("<p><a href=\"/6B1/chiudi\"><button class=\"button\">CHIUDI PORTA 6B1</button></a><stato class=\"stato\">" + Door6B1 + "</p>");
 client.println("<p><a href=\"/6B2/chiudi\"><button class=\"button\">CHIUDI PORTA 6B2</button></a><stato class=\"stato\">" + Door6B2 + "</p>");
 client.println("<p><a href=\"/7B1/chiudi\"><button class=\"button\">CHIUDI PORTA 7B1</button></a><stato class=\"stato\">" + Door7B1 + "</p>");
 client.println("<p><a href=\"/7B2/chiudi\"><button class=\"button\">CHIUDI PORTA 7B2</button></a><stato class=\"stato\">" + Door7B2 + "</p>");
 client.println("<p><a href=\"/7A1/chiudi\"><button class=\"button\">CHIUDI PORTA 7A1</button></a><stato class=\"stato\">" + Door7A1 + "</p>");
 client.println("<p><a href=\"/All/chiudi\"><button class=\"button\">CHIUDI TUTTE</button></a></p>");   
 client.println("<p><a href=\"/Gestione\"><button class=\"button\">Gestione Orario</button></a></p>"); 
                                                                                                                                                        //FINE PAGINA HOME

  break;
  }} else {currentLine = "";}
    } else if (c != '\r') {  
            currentLine += c;}}}      
  header = "";
  client.stop();}                                          //CHIUDI LA CONNESSIONE           
}

void oraprogrammata()
{
  unsigned long Ore = NTPTime.getHours();                  //LEGGI ORE
  unsigned long Minuti = NTPTime.getMinutes();             //LEGGI MINUTI
  unsigned long Secondi = NTPTime.getSeconds();            //LEGGI SECONDI
  if (Ore == Ora && Minuti == Min && Secondi == Sec){         //ORARIO CHIUSURA AUTOMATICA
    azionebottone();}
    if (Ore == Ora1 && Minuti == Min1 && Secondi == Sec1){       //ORARIO CHIUSURA AUTOMATICA
      azionebottone();}
      if (Ore == Ora2 && Minuti == Min2 && Secondi == Sec2){     //ORARIO CHIUSURA AUTOMATICA
        azionebottone();}
}

void azionebottone()
{
  mp3_play();                                              //START AUDIO SD
  delay(5800);               
  mp3_stop();
  tone(piezoPIN, 2500, 500);                               //INIZIO BUZZER
  delay(900);
  tone(piezoPIN, 2500, 500);
  delay(900);
  tone(piezoPIN, 2500, 1200);
  delay(1300);                                             //FINE BUZZER
  myservo.write(140);                                      //INIZIO SERVO
  delay(1000);                 
  myservo.write(50);                                       //FINE SERVO
  delay(1000);
}

void sonar()
{
  delay(25);
  digitalWrite(trigPIN, LOW);
  delayMicroseconds(2);                                   //ACCENDE SONAR IN 2 MICROSECONDI
  digitalWrite(trigPIN, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPIN, LOW);                             //LEGGE TEMPO DI RITORNO ONDA IN 10 MICROSECONDI
  durata = pulseIn(echoPIN, HIGH);
  distanza = durata*0.034/2;                              //CALCOLA DISTANZA
  Serial.print("Distanza: ");
  Serial.println(distanza);
  if (distanza <= 20){
    Door7B1 = "Aperta";}
    else {
      Door7B1 = "Chiusa";}
  delay(25);
}

void memore()
{
  if(WBServer.hasArg("Ora")){
  if(WBServer.hasArg("Min")){
  if(WBServer.hasArg("Sec")){
   Orastring = WBServer.arg("Ora");
    Minstring = WBServer.arg("Min");
     Secstring = WBServer.arg("Sec");}}
  Ora = Orastring.toInt();
  Min = Minstring.toInt();
  Sec = Secstring.toInt();}
  if(WBServer.hasArg("Ora1")){
  if(WBServer.hasArg("Min1")){
  if(WBServer.hasArg("Sec1")){
   Orastring1 = WBServer.arg("Ora1");
    Minstring1 = WBServer.arg("Min1");
     Secstring1 = WBServer.arg("Sec1");}}
  Ora1 = Orastring1.toInt();
  Min1 = Minstring1.toInt();
  Sec1 = Secstring1.toInt();}
  if(WBServer.hasArg("Ora2")){
  if(WBServer.hasArg("Min2")){
  if(WBServer.hasArg("Sec2")){
   Orastring2 = WBServer.arg("Ora2");
    Minstring2 = WBServer.arg("Min2");
     Secstring2 = WBServer.arg("Sec2");}}
  Ora2 = Orastring2.toInt();
  Min2 = Minstring2.toInt();
  Sec2 = Secstring2.toInt();}
  delay(25);
}

Well every time you submit a form you do read the values but do not respond by sending a webpage that contains these values. Does that make sense ? My Italian is not so good, so the comments in your code are helping me less that way.
i usually do what you have in memore() and let that follow by putting the responding webpage in a String

String s;
s+="the web page":  // etc

and then do WBServer.send(200, "text/html", s);Now if you submit the form and the values are read from the arguments, you can show them to the user straight away afterwards
Oh and your loop() i think it is missing the WBServer.handleClient(); like this your memore() never gets called !!WBServer.on("/Gestione/salva", memore); in setup() requires .handleClient() within loop() yes like this it doesn't work. So in recap i don't use the whole client.println() thing, just the ESPwebServer. You use both (i've done that once too, it doesn't work) Check out the AdvancedWebServer example under ESPwebserver. Sorry i have no more time today.

oh yeahWBServer.begin(); is also missing in setup()

So today i had a bit more time, and took it.. I awarded you a karma point for writing proper HTML-code (which is also the reason i went through the trouble of showing this a bit more clear. So as you suspected there was something structurally wrong and i came to this using a lot of your code

#include <ESP8266WebServer.h>
#include <ESP8266WebServerSecure.h>
#include <SoftwareSerial.h>
#include <stdlib.h>
#include <WiFiUdp.h>
#include <WiFiClient.h>
//#include <NTPClient.h>
#include <Servo.h>
//#include <DFPlayer.h>

const char* ssid = "SSID";                             //SSID WIFI
const char* password = "PASSWORD";                     //PASSWORD WIFI
ESP8266WebServer WBServer(80);
WiFiUDP ntpUDP;
//NTPClient NTPTime (ntpUDP, "ntp1.inrim.it", 3600);            //SERVER NTP E GMT (3600 +1)
Servo myservo;
const int buttonPIN = D5;
const int piezoPIN = D6;
const int trigPIN = D4;
const int echoPIN = D3;
long durata;
int distanza;
SoftwareSerial mp3Serial(D1, D2);
#define PIN_BUSY D10
// WiFiServer server(80);                                        //PORTA SITO WEB
String header;                                                //HEADER SITO WEB
String Door6A1;
String Door6A2;
String Door6B1;
String Door6B2;
String Door7B1;
String Door7B2;
String Door7A1;
int Ora;
int Min;
int Sec;
int Ora1;
int Min1;
int Sec1;
int Ora2;
int Min2;
int Sec2;


void setup()
{
  myservo.write(50);
  Serial.begin(9600);
  delay(250);
  mp3Serial.begin (9600);
  delay(250);
  myservo.attach(13);
  pinMode (buttonPIN, INPUT_PULLUP);
  pinMode (piezoPIN, OUTPUT);
  pinMode (trigPIN, OUTPUT);
  pinMode (echoPIN, INPUT);
  //mp3_set_serial (mp3Serial);
  delay(1500);
  //mp3_set_volume (28);
  delay(2000);
  WiFi.begin(ssid, password);
  delay(2000);

  WBServer.on("/6A1/chiudi",D6A1);
  WBServer.on("/Gestione/salva", Memore);
  WBServer.on("/Gestione", Gestione);
  WBServer.on("/",handleRoot);
  WBServer.begin();
}

void loop() {
  WBServer.handleClient();
  int buttonState = digitalRead(buttonPIN);                 //LEGGI STATO BOTTONE
  if (buttonState == LOW) {
    //azionebottone();
  }
  else {
    //NTPTime.update();                                   //AGGIORNA ORA DA NTP
    //oraprogrammata();                                   //LOOP ORARIO PROGRAMMATO
  }
}

void D6A1() {
  
}


void handleRoot() {
  String s = "";
  s += "<!DOCTYPE html><html>";
  s += "<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">";
  s += "<link rel=\"icon\" href=\"data:,\">";
  s += "<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}";
  s += ".button { background-color: #195B6A; border: none; color: white; padding: 16px 40px;";
  s += "text-decoration: none; font-size: 30px; margin: 2px; cursor: pointer;}";
  s += ".stato { border: none; color: #195B6A; padding: 16px 40px;";
  s += "text-decoration: none; font-size: 30px; margin: 2px; cursor: pointer;}";
  s += "</style></head>";
  s += "<body><h1>Althea Italia S.p.A.
Controllo remoto chiusura porte
</h1>";
  s += "<p><a href=\"/6A1/chiudi\"><button class=\"button\">CHIUDI PORTA 6A1</button></a><stato class=\"stato\">" + Door6A1 + "</p>";
  s += "<p><a href=\"/6A2/chiudi\"><button class=\"button\">CHIUDI PORTA 6A2</button></a><stato class=\"stato\">" + Door6A2 + "</p>";
  s += "<p><a href=\"/6B1/chiudi\"><button class=\"button\">CHIUDI PORTA 6B1</button></a><stato class=\"stato\">" + Door6B1 + "</p>";
  s += "<p><a href=\"/6B2/chiudi\"><button class=\"button\">CHIUDI PORTA 6B2</button></a><stato class=\"stato\">" + Door6B2 + "</p>";
  s += "<p><a href=\"/7B1/chiudi\"><button class=\"button\">CHIUDI PORTA 7B1</button></a><stato class=\"stato\">" + Door7B1 + "</p>";
  s += "<p><a href=\"/7B2/chiudi\"><button class=\"button\">CHIUDI PORTA 7B2</button></a><stato class=\"stato\">" + Door7B2 + "</p>";
  s += "<p><a href=\"/7A1/chiudi\"><button class=\"button\">CHIUDI PORTA 7A1</button></a><stato class=\"stato\">" + Door7A1 + "</p>";
  s += "<p><a href=\"/All/chiudi\"><button class=\"button\">CHIUDI TUTTE</button></a></p>";
  s += "<p><a href=\"/Gestione\"><button class=\"button\">Gestione Orario</button></a></p>";
  WBServer.send(200, "text/html", s);
}

This compiles for me, but that meant i had to get rid of some stuff like the NTP thing and mp3 thing, but you should manage to put that back in. Also i removed the responses to all the individual 'door-buttons' but left you 1 example. I hope the structure of how to do what you want is now clear enough, basically you setup callback functions to web-page addresses, and if these contain arguments you can extract their values. Those String variables should probably actually be local to function that uses them or you may get some fragmentation issue at some point. (in my experience it is fine to use the String class on an ESP(it has a lot of memory), as long as you keep the variables either 'local' or reserve space for them.

void Memore() {
  String Orastring;
  String Minstring;
  String Secstring;
  String Orastring1;
  String Minstring1;
  String Secstring1;
  String Orastring2;
  String Minstring2;
  String Secstring2;
  if (WBServer.hasArg("Ora")) {
    if (WBServer.hasArg("Min")) {
      if (WBServer.hasArg("Sec")) {
        Orastring = WBServer.arg("Ora");
        Minstring = WBServer.arg("Min");
        Secstring = WBServer.arg("Sec");
      }
    }
    Ora = Orastring.toInt();
    Min = Minstring.toInt();
    Sec = Secstring.toInt();
  }
  if (WBServer.hasArg("Ora1")) {
    if (WBServer.hasArg("Min1")) {
      if (WBServer.hasArg("Sec1")) {
        Orastring1 = WBServer.arg("Ora1");
        Minstring1 = WBServer.arg("Min1");
        Secstring1 = WBServer.arg("Sec1");
      }
    }
    Ora1 = Orastring1.toInt();
    Min1 = Minstring1.toInt();
    Sec1 = Secstring1.toInt();
  }
  if (WBServer.hasArg("Ora2")) {
    if (WBServer.hasArg("Min2")) {
      if (WBServer.hasArg("Sec2")) {
        Orastring2 = WBServer.arg("Ora2");
        Minstring2 = WBServer.arg("Min2");
        Secstring2 = WBServer.arg("Sec2");
      }
    }
    Ora2 = Orastring2.toInt();
    Min2 = Minstring2.toInt();
    Sec2 = Secstring2.toInt();
  }
    
  String s = "";                                                                                           //INIZIO PAGINA GESTIONE
  s += "<!DOCTYPE html><html>";
  s += "<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">";
  s += "<link rel=\"icon\" href=\"data:,\">";
  s += "<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}";
  s += ".button { background-color: #195B6A; border: none; color: white; padding: 16px 40px;";
  s += "text-decoration: none; font-size: 30px; margin: 2px; cursor: pointer;}";
  s += ".stato { border: none; color: #195B6A; padding: 16px 40px;";
  s += "text-decoration: none; font-size: 30px; margin: 2px; cursor: pointer;}";
  s += "</style></head>";
  s += "<body><h1>Althea Italia S.p.A.
Controllo remoto chiusura porte
Potete inserire fino a 3 orari programmati per la chiusura delle porte
</h1>";
  
  s += "<body><h1>Gli orari attualmente impostati sono:</h1>
";
  s += "<p><strong>Orario1: " + Orastring + ":" + Minstring + ":" + Secstring + " </p></strong>
";
  s += "<p><strong>Orario2: " + Orastring1 + ":" + Minstring1 + ":" + Secstring1 + " </p></strong>
";
  s += "<p><strong>Orario3: " + Orastring2 + ":" + Minstring2 + ":" + Secstring2 + " </p></strong>
";
  s += "<p><a href=\"Indietro\"><button class=\"button\">Indietro</button></a></p>";
  WBServer.send(200, "text/html", s);
}

Darn 9000 chars rule !!

Ah sorry Gestione uses the Strings as well (moved them after the compile check) it should look like this

void Gestione() {
  String Orastring=String (Ora,DEC);
  String Minstring=String (Min,DEC);
  String Secstring=String (Sec,DEC);
  String Orastring1=String (Ora1,DEC);
  String Minstring1=String (Min1,DEC);
  String Secstring1=String (Sec1,DEC);
  String Orastring2=String (Ora2,DEC);
  String Minstring2=String (Min2,DEC);
  String Secstring2=String (Sec2,DEC);
  String s = "";                                                                                           //INIZIO PAGINA GESTIONE
  s += "<!DOCTYPE html><html>";
  s += "<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">";
  s += "<link rel=\"icon\" href=\"data:,\">";
  s += "<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}";
  s += ".button { background-color: #195B6A; border: none; color: white; padding: 16px 40px;";
  s += "text-decoration: none; font-size: 30px; margin: 2px; cursor: pointer;}";
  s += ".stato { border: none; color: #195B6A; padding: 16px 40px;";
  s += "text-decoration: none; font-size: 30px; margin: 2px; cursor: pointer;}";
  s += "</style></head>";
  s += "<body><h1>Althea Italia S.p.A.
Controllo remoto chiusura porte
Potete inserire fino a 3 orari programmati per la chiusura delle porte
</h1>";
  s += "<form action=\"/Gestione/salva\" method=\"post\">";
  s += "Orario 1: <input type='text' name='Ora' id='Ora' size=2 autofocus> : <input type='text' name='Min' id='Min' size=2 autofocus> : <input type='text' name='Sec' id='date_ss' size=2 autofocus>

";
  s += "Orario 2: <input type='text' name='Ora1' id='Ora1' size=2 autofocus> : <input type='text' name='Min1' id='Min1' size=2 autofocus> : <input type='text' name='Sec1' id='Sec1' size=2 autofocus>

";
  s += "Orario 3: <input type='text' name='Ora2' id='Ora2' size=2 autofocus> : <input type='text' name='Min2' id='Min2' size=2 autofocus> : <input type='text' name='Sec2' id='Sec2' size=2 autofocus>

";
  s += "<input type=submit value=Salva>


";
  s += "</form>";
  s += "<body><h1>Gli orari attualmente impostati sono:</h1>
";
  s += "<p><strong>Orario1: " + Orastring + ":" + Minstring + ":" + Secstring + " </p></strong>
";
  s += "<p><strong>Orario2: " + Orastring1 + ":" + Minstring1 + ":" + Secstring1 + " </p></strong>
";
  s += "<p><strong>Orario3: " + Orastring2 + ":" + Minstring2 + ":" + Secstring2 + " </p></strong>
";
  s += "<p><a href=\"Indietro\"><button class=\"button\">Indietro</button></a></p>";
  WBServer.send(200, "text/html", s);
}

IT WORKS! :smiley:

Actually the error was pretty stupid! :slight_smile:
I made confusion with the WiFiServer server(80); in my void setup declaration and function.
client.println wasn't about WBServer

Now, i've to make two NodeMCU under the same wifi talk to eachother... but I think i'm gonna open another topic for this. Can I count on your help?

REALLY, THANKS! this was really helpful!

THANK YOU, THANK YOU, THANK YOU! :smiley:

You're welcome !