Few explanations: the code above is a part only of the overall program (dealing with RFID and LCD).
The variable readString is the http request. For this part of the program, readString = setup?SBM=1&DT1=192&DT2=168&DT3=0&DT4=20&DT5=255&DT6=255&DT7=255&DT8=0&DT9=192&DT10=168&DT11=0&DT12=2
I've used few lines of another project I found on the web (thanks to Jori : http://www.jo3ri.be/arduino/arduino-projects/network-settings-web-page-form-using-eeprom-to-save-submit) but need to drastically change jori's code.
The entire program is quite hudge but if it can help, I can post all of it.
//***************Begin Setup Page**********************
//*********************************************************
void PageSetup()
{
char readStringchar[150];
char buffer[150];
char *pos,*key,*data;
char *keyarray[25];
char *dataarray[25];
readString.toCharArray(readStringchar, 150);
int i=0;
key = pos = readStringchar;
while(*pos)
{
switch(*pos)
{
case '=':
*pos = 0;
pos++;
data = pos;
break;
case '&':
*pos = 0;
Serial.print("Key: ");
Serial.print(key);
keyarray[i] = key;
Serial.print(" Value: ");
Serial.println(data);
dataarray[i] = data;
pos++;
i++;
key = pos;
break;
}
pos++;
}
Serial.print("Key: ");
Serial.print(key);
Serial.print(" Value: ");
Serial.println(data);
//keyarray[i] = key;
//dataarray[i] = data;
for (int i = 0 ; i < 4; i++){
Serial.print ("ip");
Serial.println (ip[i]); }
for (int i = 0 ; i < 4; i++){
Serial.print ("subnet");
Serial.println (subnet[i]); }
for (int i = 0 ; i < 4; i++){
Serial.print ("gw");
Serial.println (gateway[i]); }
if (readString.indexOf("SBM")>0){
Serial.println ("ok SBM");
for (int i = 1 ; i < 5; i++){
ip[i] = int(dataarray[i]);
Serial.print ("ip");
Serial.println (ip[i]); }
for (int i = 1 ; i < 5; i++){
subnet[i] = byte(*dataarray[i+4]);
Serial.print ("subnet");
Serial.println (subnet[i]); }
for (int i = 1 ; i < 5; i++){
gateway[i] = byte(*dataarray[i+8]);
Serial.print ("gw");
Serial.println (gateway[i]); }
// save to EEPROM
/* for (int i = 1 ; i < 5; i++){
EEPROM.write(i, ip[i]);
}
for (int i = 1 ; i < 5; i++){
EEPROM.write(i + 4, subnet[i]);
}
for (int i = 1 ; i < 5; i++){
EEPROM.write(i + 8, gateway[i]);
}
// set ID to the known bit
EEPROM.write(0, 0x92);
*/
}//End if SBM
//ShieldSetup();
server.begin(); //starting the server
EthernetClient client = server.available();
char c;
if (client) {
Serial.println ("If CLient");
boolean currentLineIsBlank = true;
Serial.println ("While client connected");
if (client.available()) {
Serial.println ("If CLient Available");
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
for (int i = 0; i < 4; i++)
{
strcpy_P(buffer, (char*)pgm_read_word(&(string_table0[i])));
client.print( buffer );
}
strcpy_P(buffer, (char*)pgm_read_word(&(string_table1[0])));
client.print( buffer );
strcpy_P(buffer, (char*)pgm_read_word(&(string_table2[0])));
client.print( buffer );
client.print(ip[0],DEC);
strcpy_P(buffer, (char*)pgm_read_word(&(string_table2[1])));
client.print( buffer );
client.print(ip[1],DEC);
strcpy_P(buffer, (char*)pgm_read_word(&(string_table2[2])));
client.print( buffer );
client.print(ip[2],DEC);
strcpy_P(buffer, (char*)pgm_read_word(&(string_table2[3])));
client.print( buffer );
client.print(ip[3],DEC);
strcpy_P(buffer, (char*)pgm_read_word(&(string_table3[0])));
client.print( buffer );
client.print(subnet[0],DEC);
strcpy_P(buffer, (char*)pgm_read_word(&(string_table3[1])));
client.print( buffer );
client.print(subnet[1],DEC);
strcpy_P(buffer, (char*)pgm_read_word(&(string_table3[2])));
client.print( buffer );
client.print(subnet[2],DEC);
strcpy_P(buffer, (char*)pgm_read_word(&(string_table3[3])));
client.print( buffer );
client.print(subnet[3],DEC);
strcpy_P(buffer, (char*)pgm_read_word(&(string_table4[0])));
client.print( buffer );
client.print(gateway[0],DEC);
strcpy_P(buffer, (char*)pgm_read_word(&(string_table4[1])));
client.print( buffer );
client.print(gateway[1],DEC);
strcpy_P(buffer, (char*)pgm_read_word(&(string_table4[2])));
client.print( buffer );
client.print(gateway[2],DEC);
strcpy_P(buffer, (char*)pgm_read_word(&(string_table4[3])));
client.print( buffer );
client.print(gateway[3],DEC);
strcpy_P(buffer, (char*)pgm_read_word(&(string_table4[4])));
client.print( buffer );
strcpy_P(buffer, (char*)pgm_read_word(&(string_table4[5])));
client.print( buffer );
}//end If Client.available
delay(5);
Serial.println("Client Stop");
client.stop();
// }// End While Client
readString="";
}//End If Client
}//End Void
//***************End Setup Page**********************
//*********************************************************