WebServer Issue loading pages and commands not working

Hi to everyone,
I've got a problem with my actual project (I'm new about programming and arduino),
my hardware setup is : Arduino Nano, ethernet shield ENC28J60 (for Nano).
The problem is that i'm new about this programming world and i don't have enough knowledge about TCP and HTTP comunication. However in my actual project i've to create a webserver with two pages that controls a network configuration and the other page have to control 6 relays. The two programs works when are separated, but i've got a lot of bugs and loading problems when I combine them together.
I think that the problem is correlated with the TCP connection or HTTP requests.
Here is the code, i hope someone can help me:

#include <UIPEthernet.h>
#include <TextFinder.h>
#include <SPI.h>
#include <EEPROM.h>
#include <avr/pgmspace.h>
  
//PIN definition 
#define RESET 9 //pin per reset manuale
const byte INDEX = 4;  //Array dimension (ip, mask, gw, dns)
const byte RELE_NUM = 6;
const PROGMEM byte rele_pin[RELE_NUM] = {2, 3, 8, 5, 6, 7};

//Reset states
int lastState = LOW;  // the previous state from the input pin
int currentState = digitalRead(RESET);
 
//Default Network Settings
const PROGMEM byte default_mac[RELE_NUM] = { 0x00,0x01,0x02,0x03,0x04,0x05 };
const PROGMEM byte default_ip[INDEX] = { 192,168,65,250 };
const PROGMEM byte default_subnet[INDEX] = { 255,255,255,0 };
const PROGMEM byte default_gateway[INDEX] = { 192,168,65,254 };

//Start Network Settings
byte mac[RELE_NUM] = { 0x00,0x01,0x02,0x03,0x04,0x05 };
byte ip[INDEX] = {192,168,65,250};
byte subnet[INDEX] = {255,255,255,0};
byte gateway[INDEX] = {192,168,65,254};
byte dnsserver[INDEX] = {192,168,65,2};

EthernetServer server(80);
EthernetClient client;

//Buffers
char buffer[100]; //buffer string_tables (it has to be as big as the longest character chain +1 including the " )
String Read;


const char htmla0[] PROGMEM = "<script>function hex2num (s_hex) {eval(\"var n_num=0X\" + s_hex);return n_num;}";
const char htmla1[] PROGMEM = "</script><table><form><input type=\"hidden\" name=\"SBM\" value=\"1\"><tr><td>";
const char htmla2[] PROGMEM = "<font color= #FFFFFF>MAC:<input id=\"T1\" type=\"text\" size=\"3\" maxlength=\"";
const char htmla3[] PROGMEM = "2\" name=\"DT1\" value=\"";
const char htmla4[] PROGMEM = "\">.<input id=\"T3\" type=\"text\" size=\"3\" maxlength=\"2\" name=\"DT2\" value=\"";
const char htmla5[] PROGMEM = "\">.<input id=\"T5\" type=\"text\" size=\"3\" maxlength=\"2\" name=\"DT3\" value=\"";
const char htmla6[] PROGMEM = "\">.<input id=\"T7\" type=\"text\" size=\"3\" maxlength=\"2\" name=\"DT4\" value=\"";
const char htmla7[] PROGMEM = "\">.<input id=\"T9\" type=\"text\" size=\"3\" maxlength=\"2\"name=\"DT5\" value=\"";
const char htmla8[] PROGMEM = "\">.<input id=\"T11\" type=\"text\" size=\"3\" maxlength=\"2\"name=\"DT6\" value=\"";

PGM_P const string_table1[] PROGMEM = { htmla0, htmla1, htmla2, htmla3, htmla4, htmla5, htmla6, htmla7, htmla8 };

const char htmlb0[] PROGMEM = "\"><input id=\"T2\" type=\"hidden\" name=\"DT1\"><input id=\"T4\" type=\"hidden\" name=\"DT2";
const char htmlb1[] PROGMEM = "\"><input id=\"T6\" type=\"hidden\" name=\"DT3\"><input id=\"T8\" type=\"hidden\" name=\"DT4";
const char htmlb2[] PROGMEM = "\"><input id=\"T10\" type=\"hidden\" name=\"DT5\"><input id=\"T12\" type=\"hidden\" name=\"D";
const char htmlb3[] PROGMEM = "T6\"></td></tr></font><tr><td><font color= #FFFFFF>";  
const char htmlb4[] PROGMEM = "IP: <input type=\"text\" size=\"3\"maxlength=\"3\" name=\"DT7\"value=\"";
const char htmlb5[] PROGMEM = "\">.<input type=\"text\" size=\"3\" maxlength=\"3\"name=\"DT8\" value=\""; 
const char htmlb6[] PROGMEM = "\">.<input type=\"text\" size=\"3\" maxlength=\"3\" name=\"DT9\" value=\"";
const char htmlb7[] PROGMEM = "\">.<input type=\"text\" size=\"3\" maxlength=\"3\" name=\"DT10\" value=\"";

PGM_P const string_table2[] PROGMEM = { htmlb0, htmlb1, htmlb2, htmlb3, htmlb4, htmlb5, htmlb6, htmlb7 };

const char htmlc0[] PROGMEM = "\"></td></tr></font><tr><td><font color= #FFFFFF>MASK: <input type=\"text\"";
const char htmlc1[] PROGMEM = "size=\"3\" maxlength=\"3\" name=\"DT11\" value=\"";
const char htmlc2[] PROGMEM = "\">.<input type=\"text\" size=\"3\" maxlength=\"3\" name=\"DT12\" value=\"";
const char htmlc3[] PROGMEM = "\">.<input type=\"text\" size=\"3\" maxlength=\"3\" name=\"DT13\" value=\"";
const char htmlc4[] PROGMEM = "\">.<input type=\"text\" size=\"3\" maxlength=\"3\" name=\"DT14\" value=\"";

PGM_P const string_table3[]  PROGMEM = { htmlc0, htmlc1, htmlc2, htmlc3, htmlc4 };

const char htmld0[] PROGMEM = "\"></td></tr></font><tr><td><font color= #FFFFFF>GW: <input type=\"text\"";
const char htmld1[] PROGMEM = "size=\"3\" maxlength=\"3\" name=\"DT15\" value=\"";
const char htmld2[] PROGMEM = "\">.<input type=\"text\" size=\"3\" maxlength=\"3\" name=\"DT16\" value=\"";
const char htmld3[] PROGMEM = "\">.<input type=\"text\" size=\"3\" maxlength=\"3\" name=\"DT17\" value=\"";
const char htmld4[] PROGMEM = "\">.<input type=\"text\" size=\"3\" maxlength=\"3\" name=\"DT18\" value=\"";
const char htmld5[] PROGMEM = "\"></td></tr></font><tr><td><br></td></tr><tr><td><input class=\"button\""; 
const char htmld6[] PROGMEM = "id=\"submit\" type=\"submit\"value=\"SUBMIT\"><input class=\"button\" id=\"";
const char htmld7[] PROGMEM = "reset\" type=\"reset\" value=\"RESET\"></td></tr></form></table></body></html>";

PGM_P const string_table4[] PROGMEM = { htmld0, htmld1, htmld2, htmld3, htmld4, htmld5, htmld6, htmld7 };

const char htmle0[] PROGMEM = "Onclick=\"document.getElementById('T2').value ";
const char htmle1[] PROGMEM = "= hex2num(document.getElementById('T1').value);";
const char htmle2[] PROGMEM = "document.getElementById('T4').value = hex2num(document.getElementById('T3').value);";
const char htmle3[] PROGMEM = "document.getElementById('T6').value = hex2num(document.getElementById('T5').value);";
const char htmle4[] PROGMEM = "document.getElementById('T8').value = hex2num(document.getElementById('T7').value);";
const char htmle5[] PROGMEM = "document.getElementById('T10').value = hex2num(document.getElementById('T9').value);";
const char htmle6[] PROGMEM = "document.getElementById('T12').value = hex2num(document.getElementById('T11').value);\"";

PGM_P const string_table5[] PROGMEM = { htmle0, htmle1, htmle2, htmle3, htmle4, htmle5, htmle6 };

const char buttons0[] PROGMEM = "<!DOCTYPE html><html><body><head><meta name=\"viewport\" content=\"width=device-width,";
const char buttons1[] PROGMEM = "initial-scale=1.0\"><!-- Icon library --><link rel=\"stylesheet\" href=\"https://cdnjs.";
const char buttons2[] PROGMEM = "cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css\"><style> * ";
const char buttons3[] PROGMEM = "{ box-sizing: border-box;}body{ margin: 0; background-color: #000000; background-image:";
const char buttons4[] PROGMEM = "url('wallpaper.jpg'); background-size: cover;}"; // Style the header
const char buttons5[] PROGMEM = ".header{ background-image: url('logo.png'); background-repeat: no-repeat; background-size:";
const char buttons6[] PROGMEM = "contain; background-color: #000000; color: #f2f2f2; padding: 20px; text-align: center;}"; // Style the top navigation bar 
const char buttons7[] PROGMEM = ".topnav { overflow: hidden; background-color: #000000;}"; // Style the topnav links 
const char buttons8[] PROGMEM = ".topnav a{ float: left; display: block; color: #f2f2f2; text-align: center; padding:";
const char buttons9[] PROGMEM = "14px 16px; text-decoration: none;}"; // Change color on hover 
const char buttons10[] PROGMEM = ".topnav a:hover{ background-color: #ddd; color: black;}"; // Buttons Style 
const char buttons11[] PROGMEM = ".button{ display: inline-block; padding: 15px 25px; font-size: 24px; cursor: pointer;";
const char buttons12[] PROGMEM = "text-align: center; text-decoration: none; outline: none; color: black; background-color:";
const char buttons13[] PROGMEM = "white; border: 2px solid #555555; border-radius: 15px; box-shadow: 0 9px #999;}";
const char buttons14[] PROGMEM = ".button:hover { background-color: #555555; color: white;}.button:active{ background-color:";
const char buttons15[] PROGMEM = "#3e8e41; box-shadow: 0 5px #666; transform: translateY(4px);}"; // Center the Buttons
const char buttons16[] PROGMEM = ".center{ margin: 0; position: absolute; top: 35%; left: 50%; -ms-transform: translate(-50%,";
const char buttons17[] PROGMEM = "-50%); transform: translate(-50%, -50%);}</style></head><body marginwidth= 0 marginheight=0";
const char buttons18[] PROGMEM = "leftmargin=0 style= margin: 0; padding: 0;><div class=\"header\"><h1></h1></div><div class=";
const char buttons19[] PROGMEM = "\"topnav\"><a href=\"settings\">Settings</a><a href=\"commands\">Commands</a></div><body><tr>";
const char buttons20[] PROGMEM = "<div class=\"center\">";
const char buttons21[] PROGMEM = "<button class=\"button\"Onclick=location.href=\"/play\"><i class=\"fa fa-play\"></i> PLAY</button>";
const char buttons22[] PROGMEM = "<button class=\"button\"Onclick=location.href=\"/pause\"><i class=\"fa fa-pause\"></i> PAUSE</button>";
const char buttons23[] PROGMEM = "<button class=\"button\" Onclick=location.href=\"/stop\"><i class=\"fa fa-stop\"></i> STOP</button>";
const char buttons24[] PROGMEM = "<tr><br /><br />";
const char buttons25[] PROGMEM = "<button class=\"button\"Onclick=location.href=\"/ffd\"><i class=\"fa fa-fast-forward\">";
const char buttons26[] PROGMEM = "</i> FFD</button><button class=\"button\" Onclick=location.href=\"/reverse\">"; 
const char buttons27[] PROGMEM = "<i class=\"fa fa-fast-backward\"></i> REVERSE</button><button class=\"button\"";
const char buttons28[] PROGMEM = " Onclick=location.href=\"/record\"><i class=\"fa fa-circle\"></i> REC</button></body></html>";

PGM_P const string_buttons[] PROGMEM = { buttons0, buttons1, buttons2, buttons3, buttons4, buttons5, buttons6, buttons7, buttons8, buttons9, buttons10,
                                         buttons11, buttons12, buttons13, buttons14, buttons15, buttons16, buttons17, buttons18, buttons19, buttons20,
                                         buttons21, buttons22, buttons23, buttons24, buttons25, buttons26, buttons27, buttons28 };

const byte ID = 0x92; //used to identify if valid data in EEPROM the "know" bit, 
// if this is written in EEPROM the sketch has ran before
// We use this, so that the very first time you'll run this sketch it will use
// the values written above. 
// defining which EEPROM address we are using for what data

void setup()
{
   
  Serial.begin(9600);
  
  //Reset button
  pinMode(RESET, INPUT);
  
  //Relays
  for (size_t j= 0; j < RELE_NUM; j++)
  {
    pinMode(rele_pin[j], OUTPUT);  //setto i rele come OUTPUT
    digitalWrite((j+2), LOW);  //setto i rele LOW
  }
  
  ShieldSetup (); //Setup the Ethernet shield

  server.begin(); //starting the server
  Serial.print(F("Server start at: "));
  Serial.println(Ethernet.localIP());
}

void ShieldSetup()
{
  
  Serial.println(F("Ethernet Shield setup..."));
  int idcheck = EEPROM.read(0);

  if (idcheck != ID)
  {
    //ifcheck id is not the value as const byte ID,
    //it means this sketch has NOT been used to setup the shield before
    //just use the values written in the beginning of the sketch
  }
  if (idcheck == ID)
  {
    //if id is the same value as const byte ID,
    //it means this sketch has been used to setup the shield.
    //So we will read the values out of EERPOM and use them
    //to setup the shield.
    for (size_t i = 0; i < 6; i++){
      mac[i] = EEPROM.read(i+1);
    }
    for (size_t i = 0; i < 4; i++){
      ip[i] = EEPROM.read(i+7);
    }
    for (size_t i = 0; i < 4; i++){
      subnet[i] = EEPROM.read(i+11);
    }
    for (size_t i = 0; i < 4; i++){
      gateway[i] = EEPROM.read(i+15);
    }
  }
  
  Ethernet.begin(mac, ip);
}

void web_page()
{
  EthernetClient client = server.available();
  if (client) //Indicates if the specified Ethernet client is ready.  
  {    
    Serial.println(F("Settings Client"));
    TextFinder finder(client);
    while (client.connected()) //Whether or not the client is connected
    {       
      if (client.available()) //Is the amount of data that has been written to the client by the server it is connected to
      {                           
        if( finder.find("GET /") ) //This part does all the text searching
        {   
         if (finder.findUntil("settings", "\n\r"))
         {    
            Serial.println(F("* Settings *"));  
            // if you find the word "SBM" continue looking for more
            // if you don't find that word, stop looking and go further
            // it means the SUBMIT button hasn't been pressed an nothing has
            // been submitted. Just go to the place where the setup page is
            // been build and show it in the client's browser.  
          if (finder.findUntil("SBM", "\n\r"))
          {
            byte SET = finder.getValue();
            // Now while you are looking for the letters "DT", you'll have to remember
            // every number behind "DT" and put them in "val" and while doing so, check
            // for the according values and put those in mac, ip, subnet and gateway.
              while(finder.findUntil("DT", "\n\r"))
              {
                int val = finder.getValue();
                // if val from "DT" is between 1 and 6 the according value must be a MAC value.
                if(val >= 1 && val <= 6) 
                {
                  mac[val - 1] = finder.getValue();
                }
                // if val from "DT" is between 7 and 10 the according value must be a IP value.
                if(val >= 7 && val <= 10) 
                {
                  ip[val - 7] = finder.getValue();
                }
                // if val from "DT" is between 11 and 14 the according value must be a MASK value.
                if(val >= 11 && val <= 14) 
                {
                  subnet[val - 11] = finder.getValue();
                }
                // if val from "DT" is between 15 and 18 the according value must be a GW value.
                if(val >= 15 && val <= 18) 
                {
                  gateway[val - 15] = finder.getValue();
                }
              }
            // Now that we got all the data, we can save it to EEPROM
            for (size_t i = 0 ; i < 6; i++)
            {
              EEPROM.write(i + 1,mac[i]);
            }
            for (size_t i = 0 ; i < 4; i++)
            {
              EEPROM.write(i + 7, ip[i]);
            }
            for (size_t i = 0 ; i < 4; i++)
            {
              EEPROM.write(i + 11, subnet[i]);
            }
            for (size_t i = 0 ; i < 4; i++)
            {
              EEPROM.write(i + 15, gateway[i]);
            }
            // set ID to the known bit, so when you reset the Arduino is will use the EEPROM values
            EEPROM.write(0, 0x92); 
            Serial.println(F("Reboot with new Network settings"));
            delay(330);
            asm volatile("jmp 0");
          }
          
          // and from this point on, we can start building our setup page
          // and show it in the client's browser.
          client.println(F("HTTP/1.1 200 OK"));
          client.println(F("Content-Type: text/html"));
          client.println(F("Connection: close"));
          client.println();
          client.println(F("<html><div id=\"settings\">"));
          client.println(F("<head>"));
          client.println(F("<title>Settings</title>"));
          client.println(F("<meta charset=\"utf-8\">"));
          client.println(F("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">"));
          client.println(F("<style>"));
          client.println(F("* { box-sizing: border-box;}"));
          client.println(F("body{ margin: 0; background-color: #000000; background-image: url('wallpaper.jpg'); background-size: cover;}"));
          client.println(F(".header{ background-image: url('logo.png'); background-repeat: no-repeat; background-size: contain; background-color: #000000; color: #f2f2f2; padding: 20px; text-align: center}")); // Style the header 
          client.println(F(".topnav { overflow: hidden; background-color: #000000;}")); // Style the top navigation bar 
          client.println(F(".topnav a{ float: left; display: block; color: #f2f2f2; text-align: center; padding: 14px 16px; text-decoration: none;}")); // Style the topnav links 
          client.println(F(".topnav a:hover { background-color: #ddd; color: black;}"));// Change color on hover
          client.println(F(".center{ margin: 0; position: absolute; top: 35%; left: 50%; -ms-transform: translate(-50%, -50%); transform: translate(-50%, -50%);}"));// Center the table
          client.println(F(".button{ display: inline-block; padding: 3px 15px; font-size: 12px; cursor: pointer; text-align: center; text-decoration: none; outline: none; color: black; background-color: white; border: 2px solid #555555; border-radius: 15px; box-shadow: 0 9px #999;}"));// Buttons Style
          client.println(F(".button:hover{ background-color: #555555; color: white;}"));
          client.println(F(".button:active{ background-color: #3e8e41; box-shadow: 0 5px #666; transform: translateY(4px);}"));
          client.println(F("</style>"));
          client.println(F("</head>"));
          client.println(F("<body marginwidth= 0 marginheight=0 leftmargin=0 style= margin: 0; padding: 0;>"));
          client.println(F("<div class=\"header\">"));
          client.println(F("<h1></h1>")); 
          client.println(F("</div>"));
          client.println(F("<div class=\"topnav\">"));
          client.println(F("<a href=\"settings\">Settings</a>"));
          client.println(F("<a href=\"commands\">Commands</a>"));
          client.println(F("</div>"));
          client.println(F("<div class=\"center\">"));
          client.println(F("<table bgcolor= #999999 border= 0 width= 100% cellpadding= 1 style= font-family:Verdana;color:#fff; fff;font-size:12px;>"));
          client.println(F("<tr></tr>"));
          client.println(F("</table>"));
          client.println(F("<br>"));
          for (size_t i = 0; i < 4; i++)
          {
            strcpy_P(buffer, (char*)pgm_read_word(&(string_table1[i])));
            client.print( buffer );
          }
          client.print(mac[0],HEX);
          strcpy_P(buffer, (char*)pgm_read_word(&(string_table1[4])));
          client.print( buffer );
          client.print(mac[1],HEX);
          strcpy_P(buffer, (char*)pgm_read_word(&(string_table1[5])));
          client.print( buffer );
          client.print(mac[2],HEX);
          strcpy_P(buffer, (char*)pgm_read_word(&(string_table1[6])));
          client.print( buffer );
          client.print(mac[3],HEX);
          strcpy_P(buffer, (char*)pgm_read_word(&(string_table1[7])));
          client.print( buffer );
          client.print(mac[4],HEX);
          strcpy_P(buffer, (char*)pgm_read_word(&(string_table1[8])));
          client.print( buffer );
          client.print(mac[5],HEX);
          for (size_t i = 0; i < 5; i++)
          {
            strcpy_P(buffer, (char*)pgm_read_word(&(string_table2[i])));
            client.print( buffer );
          }
          client.print(ip[0],DEC);
          strcpy_P(buffer, (char*)pgm_read_word(&(string_table2[5])));
          client.print( buffer );
          client.print(ip[1],DEC);
          strcpy_P(buffer, (char*)pgm_read_word(&(string_table2[6])));
          client.print( buffer );
          client.print(ip[2],DEC);
          strcpy_P(buffer, (char*)pgm_read_word(&(string_table2[7])));
          client.print( buffer );
          client.print(ip[3],DEC);
          strcpy_P(buffer, (char*)pgm_read_word(&(string_table3[0])));
          client.print( buffer );
          strcpy_P(buffer, (char*)pgm_read_word(&(string_table3[1])));
          client.print( buffer );
          client.print(subnet[0],DEC);
          strcpy_P(buffer, (char*)pgm_read_word(&(string_table3[2])));
          client.print( buffer );
          client.print(subnet[1],DEC);
          strcpy_P(buffer, (char*)pgm_read_word(&(string_table3[3])));
          client.print( buffer );
          client.print(subnet[2],DEC);
          strcpy_P(buffer, (char*)pgm_read_word(&(string_table3[4])));
          client.print( buffer );
          client.print(subnet[3],DEC);
          strcpy_P(buffer, (char*)pgm_read_word(&(string_table4[0])));
          client.print( buffer );
          strcpy_P(buffer, (char*)pgm_read_word(&(string_table4[1])));
          client.print( buffer );
          client.print(gateway[0],DEC);
          strcpy_P(buffer, (char*)pgm_read_word(&(string_table4[2])));
          client.print( buffer );
          client.print(gateway[1],DEC);
          strcpy_P(buffer, (char*)pgm_read_word(&(string_table4[3])));
          client.print( buffer );
          client.print(gateway[2],DEC);
          strcpy_P(buffer, (char*)pgm_read_word(&(string_table4[4])));
          client.print( buffer );
          client.print(gateway[3],DEC);
          strcpy_P(buffer, (char*)pgm_read_word(&(string_table4[5])));
          client.print( buffer );
          for (size_t i = 0; i < 7; i++)  
          {
            strcpy_P(buffer, (char*)pgm_read_word(&(string_table5[i])));
            client.print( buffer );
          } 
          strcpy_P(buffer, (char*)pgm_read_word(&(string_table4[6])));
          client.print( buffer );
          strcpy_P(buffer, (char*)pgm_read_word(&(string_table4[7])));
          client.print( buffer );
          break;
         }
                               
       if (finder.findUntil("commands", "\n\r")) 
       { 
            Serial.println(F("* Commands *"));
            char c = client.read();
            if (Read.length() < 100) //read char by char HTTP request
            {        
              Read += c; //store characters to string
              //Serial.print(c);
            } 
            if (c == "\n")
            {  
            client.println(F("HTTP/1.1 200 OK"));
            client.println(F("Content-Type: text/html"));
            //client.println(F("Connection: close"));
            client.println();
            for (size_t i = 0; i < 29; i++)  
            {
                 strcpy_P(buffer, (char*)pgm_read_word(&(string_buttons[i])));
                 client.print( buffer );
            }

            //delay(1);
            //client.flush();
            //client.stop();
            
           Serial.println(F(">>>Commands"));
           //Controlli su Arduino: Se è stato premuto il pulsante sul webserver
           if (Read.indexOf("play") >0)
           { 
              digitalWrite(rele_pin[0], HIGH);    
              Serial.println(F(" R1_PLAY"));
              delay(1000);  
              digitalWrite(rele_pin[0], LOW);
           }
           if (Read.indexOf("pause") >0)
           {
              digitalWrite(rele_pin[1], HIGH);
              Serial.println(F(" R2_PAUSE"));
              delay(1000);  
              digitalWrite(rele_pin[1], LOW);     
           }
           if (Read.indexOf("reverse") >0)
           {
              digitalWrite(rele_pin[2], HIGH);
              Serial.println(F(" R3_REVERSE"));
              delay(1000);  
              digitalWrite(rele_pin[2], LOW);      
           }
           if (Read.indexOf("ffd") >0)
           {
              digitalWrite(rele_pin[3], HIGH);
              Serial.println(F(" R4_FAST_FORWARD"));
              delay(1000);  
              digitalWrite(rele_pin[3], LOW);             
           }
           if (Read.indexOf("stop") >0)
           {
              digitalWrite(rele_pin[4], HIGH);
              Serial.println(F(" R5_STOP"));
              delay(1000);  
              digitalWrite(rele_pin[4], LOW);
           }
           if (Read.indexOf("record") >0)
           {
              digitalWrite(rele_pin[5], HIGH);
              Serial.println(F(" R6_REC"));
              delay(1000);  
              digitalWrite(rele_pin[5], LOW);         
           }                  
           Read=""; 
          }             
         }        
       }       
      }
      delay(1);         
      client.flush(); //Ensure that all data has been sent
      client.stop();
     }
    }
}         

void reset()
{

  //Time definition
  const int PRESS_RESET = 3000;
  unsigned long pressedTime  = 0;
  unsigned long releasedTime = 0;
  
  //RESET button to default values
  if(lastState == LOW && currentState == HIGH)        // button is pressed 
  {
    //Serial.println(F("pressed"));
    pressedTime = millis();
  }
  else if(lastState == HIGH && currentState == LOW)   // button is released
  {
      //Serial.println(F("released"));
      releasedTime = millis();
      long pressDuration = releasedTime - pressedTime;

      if( pressDuration >= PRESS_RESET )
      {
        
           Serial.println(F("Resetting..."));
    
           for (size_t i = 0 ; i < RELE_NUM; i++)
           {
              EEPROM.write(i + 1, default_mac[i]);
           }
           for (size_t i = 0 ; i < INDEX; i++)
           {
              EEPROM.write(i + 7, default_ip[i]);
           }
           for (size_t i = 0 ; i < INDEX; i++)
           {
              EEPROM.write(i + 11, default_subnet[i]);
           }
           for (size_t i = 0 ; i < INDEX; i++)
           {
              EEPROM.write(i + 15, default_gateway[i]);
           }
             EEPROM.write(0, 0x92);
             lastState = currentState;          // save the the last state
             delay(330); //3.3 ms
             asm volatile("jmp 0");
      }            
  }
} 

void loop()
{
  web_page();
  reset();
  //return 0;
}



  

You need to describe those bugs and problems in detail in order for us to help you. For each bug/problem, describe what actually happens and what you wanted or expected to happen.

I see a lot of code duplicates where only minor things are changed line by line. That makes reading your code very ....

I propose you get rid of it and use more functions where you hand over the changing parts with parameters.
Furthermore, your http request doesn't contain a content length, so it is only 1.0.
Don't use the F-Makro with client.print, it will have negative effect on the performance of your webserver (and a very long communication time to your webbrowser).
I can recommend the streamlib from Juraj or - as you are already using a temporary buffer - use the buffer more consequently.

You can get more information on that topic on my page:
https://werner.rothschopf.net/microcontroller/202011_arduino_webserver_optimize_en.htm

Ok, so when the program is running i search in the browser my ip adress: 192.168.65.250/settings (to reach the setting page) and the page loads two or three times (i'll show you the serial monitor), then the page works fine it seems, but when i click to the topnav link to switch page, i've to click it a few times to reach the "commands page" and the page loading never ends, however in the serial monitor i see that the "settings page" is reloaded. I would to keep a stable connection and I'd like to make commands work, because when i click to one button nothing happends.
P.S. sorry for my bad english.

settings_page_Serial_Monitor

this is what the Serial monitor tells me when i reach the first page (* Settings *), it should be load only once.

commands_page_S_M

this is what's happen when i click to switch to the other page ((* Commands *), it reload the client and it tells me (settings) but when i click on it a few times finally i can reach the commands page. When i'm inside the other page the loading never stop, and if i try to click on one button (>>>Commands) nothing actually happens. It should tell me something like ( R1_PLAY ) when i cick to "play button".

@noiasca UIPEthernet doesn't send single bytes over network as Ethernet. (but does sent them as single bytes over SPI)

1 Like

maybe try the EthernetWebServer library.
and EthernetENC library is usually better then UIPEthernet

Thanks for the advices but i only want to know how can i how can I make the two web pages coexist in the same function "web_page(void)".
For many reasons i can't change my libraries, one of those is that i've to send the project in a few days and i'm so scared, i hope someone can help