How to fill in a value to textbox with EEPROM.read?

Hi Everybody.
I am new to arduino, and frist time to ask question in this forum.
If something worng , please let me know . THX

======question below======

I want to use textbox to save value to EEPROM.
And when I connect to this website, the value can be show in textbox by read EEPROM.

The code now is…

#include <WebServer.h>
#include <SPI.h>
#include <Ethernet.h>
#include "Streaming.h"
#include <EEPROM.h>
#include <avr/pgmspace.h>
#include <TextFinder.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
byte ip[] = {192,168,0,11};
byte subnet[] = {255,255,255,0};
byte gateway[] = {192,168,0,254};
byte dnsserver[] = {192,168,1,1};
int incomingByte = 0;
const byte ID = 0x92;

WebServer webserver("", 80);

P(htmlHead) =
 "<!doctype html><html>"
 "<head><meta charset=\"utf-8\">"
 "<title>LAB</title>"
 "</head><body>" ;
 
P(htmlFoot) = "</body></html>";

P(homePage) = 
  "<form method=\"post\" action= \"SAVECONF\">"
  "IP:<input type=\"text\" name=\"LocalIPA\" maxlength=\"3\" size=\"3\" value= \"\">."
  "<input type=\"text\" name=\"LocalIPB\" maxlength=\"3\" size=\"3\" value= \"\">."
  "<input type=\"text\" name=\"LocalIPC\" maxlength=\"3\" size=\"3\" value= \"\">."
  "<input type=\"text\" name=\"LocalIPD\" maxlength=\"3\" size=\"3\" value= \"\">

"
"
<input type=\"submit\" name=\"send\" value=\"submit and restart\">"
  "</form>";

void defaultCmd(WebServer &server, WebServer::ConnectionType type, char *, bool)
{
  server.httpSuccess();
  
  if (type != WebServer::HEAD) 
  {
    server.printP(htmlHead);    
    server.printP(homePage);
    server.printP(htmlFoot);
  }
}
void postCmd(WebServer &server, WebServer::ConnectionType type,char *, bool)
{
  char name[16], value[16];
  server.httpSuccess();

  if (type == WebServer::POST)
  {
    server.printP(htmlHead);

    while (server.readPOSTparam(name, 16, value, 16)){

       if(strcmp(name,"LocalIPA")==0){
         EEPROM.write(7,atoi(value));}
         else if(strcmp(name,"LocalIPB")==0){
         EEPROM.write(8,atoi(value));}       
         else if(strcmp(name,"LocalIPC")==0){
         EEPROM.write(9,atoi(value));}
         else if(strcmp(name,"LocalIPD")==0){
         EEPROM.write(10,atoi(value));}
         else if(strcmp(name,"send")==0){
         server << "DONE";}else{server << "error!";}
             
    }
         
         EEPROM.write(0, 0x92);
         server.printP(htmlFoot);
         asm volatile ("  jmp 0");  
                  
  }
}

void setup() {
    Ethernet.begin(mac, ip, dnsserver, gateway, subnet);
    webserver.begin(); 
    webserver.setDefaultCommand(&defaultCmd);
    webserver.addCommand("SAVECONF", &postCmd);
    Serial.begin(9600);
}

void loop() {

  webserver.processConnection();

}

Then the result as picture below

picture Link here

If fill in value in textbox , it can save to EEPROM successfully.

But…if when user connect to this web site , keep textbox blank.
Value will be save “0”.

How can I fill value in textbox with EEPROM.read automatically?

Thanks for your patient …

just so i understand you correctly. when you log onto the HTTP and enter a ip address in the text box, that IP address then gets saved to the EEPROM but if you log onto the HTTP and just view the page without entering a value then ‘0’ gets saved to the EEPROM. so you need the text box to always be filled with the correct IP address in order for the EEPROM to use the correct ip address and not delete it and save a ‘0’. ? if i am correct in my understanding then you should try adding an ‘idcheck’ to your code. that way the text box will be filled with the current IP address that is on the EEPROM.’ it will look something like this…

void ShieldSetup()
{
  int idcheck = EEPROM.read(0);
  if (idcheck != ID){

  }
  if (idcheck == ID){


    for (int i = 0; i < 4; i++){
      ip[i] = EEPROM.read(i+7);
    }

  }
  Ethernet.begin(mac, ip, dnsserver, gateway, subnet);
}

void loop()
{
  EthernetClient client = server.available();
  if (client) {
    TextFinder  finder(client );
    while (client.connected()) {      
      if (client.available()) {
        //This part does all the text searching
        if( finder.find("GET /") ) {

          if (finder.findUntil("setup", "\n\r")){

          if (finder.findUntil("SBM", "\n\r")){
            byte SET = finder.getValue();

              while(finder.findUntil("DT", "\n\r")){
                int val = finder.getValue();

  

                if(val >= 7 && val <= 10) {
                  ip[val - 7] = finder.getValue();
                }


            for (int i = 0 ; i < 6; i++){
              EEPROM.write(i + 1,mac[i]);
            }