arduino mega+ethernet shield+button switch+ toggle switch

Hi all, I have a programming question. I'm a noob and i don't know how to start so please help me.

I have an arduino mega 2560 r3 an ethernet shield 5100 and a toggle switch.
I would like to drive a small 220v lamp relay output is on pin 22
In the space below i have paste my code. This code put on or off my lamp via ip/web page, but how could I add a button (on pin 13 like input) so I could read his state and update webpage state?
Maaaaany thanks in advance

//---------------------------------------------------------

#include <Ethernet.h>
#include <SPI.h>
#include <WebServer.h> // webduino

//variabili statiche per il mac address e lìip address
static byte mac_Add[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
//cambiare l'ip in funzione della propria rete
static byte ip_Add[] = {
192, 168, 1, 220 };
//creazione Webduino
WebServer webserver("", 80);

//Variabili per la memorizzazione uscite relè
boolean Rele_Camera= false;

//=============================================================================
//funzione pagina Start
void Start(WebServer &server, WebServer::ConnectionType type,
char *url_param, bool param_complete)
{
//restituisce al browser l'intestazione http 200 OK
server.httpSuccess();

//gestisco il tipo di richiesta HEAD
if (type != WebServer::HEAD)
{
String s = "";

if (param_complete == true)
{
s = url_param;

if ( s == "R1=ON")
{
Rele_Camera = true;
digitalWrite(22, LOW);
}
else if ( s == "R1=OFF")
{
Rele_Camera = false;
digitalWrite(22, HIGH);
}
P(htmlHead) =
""
""
"Controllo Rele"
""
"";

server.printP(htmlHead);

server.print("<table border="1">");
server.print("Stato ReleComandi");

if(Rele1 == true)
server.print("<td style="color: purple;">CAMERA ON");
else
server.print("<td style="color: black;">CAMERA OFF");

if(Rele1 == false)
server.print("<input type="button" value="clicca qui""
"onclick="location.href='index.htm?R1=ON'">");
else
server.print("<input type="button" value="clicca qui""
"onclick="location.href='index.htm?R1=OFF'">");

server.print("");
server.print("");

}
}
//=============================================================================

void setup()
{
//inizializzo l'ethernet shield con il mac e il address
Ethernet.begin(mac_Add, ip_Add);

//definisci l'azione di default che verrà eseguita quando l'utente
//naviga nella root del sito
webserver.setDefaultCommand(&Start);
webserver.addCommand("index.htm", &Start);

//avvia il web server
webserver.begin();

delay(100);

//definisci pin 22
pinMode(22, OUTPUT);
//inizializza i le uscite
digitalWrite(22, HIGH);

}

void loop()
{
webserver.processConnection();
}
//END

This code put on or off my lamp via ip/web page, but how could I add a button (on pin 13 like input) so I could read his state and update webpage state?

You can't. The Arduino is a server. It responds to client requests. It can NOT push data to clients. The clients have to pull data.

You can add appropriate meta tags to have the page automatically refresh after a defined period of time.

I have understand that but my question is another.
I have this layout

lamp----------------relay(output)------------arduino------------------ethernet shield
|
|
button(input)

I could make a program to drive my lamp with the ethernet shield and also with the button, but How can I make this two think to work together?
Many thanks in advance

How can I make this two think to work together?

First, you define the requirements for the combined program.
Second, you write the program. If it does what you want, great. If not, I seem to recall that there is a site dedicated to getting help with Arduino questions. Can't remember the URL off the top of my head, but I'm sure that a little google fu will help you find it in no time.

hi all
is there any way about this?
thank you...

is there any way about this?

Until you define your requirements? No.

Dear PaulS and all.
it will be solve with your help....
check code please

#include <SPI.h>
#include <Ethernet.h>

//int led1 = 5;                
int led2 = 6;
int led3 = 7; 
int inPin = 12;
int outPin = 5;
//int LDR_Pin = A0;

int state; //= HIGH;   
int reading;       
int previous;  //= LOW; 


long time = 0;
long debounce = 200; 

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; 
byte ip[] = { 10, 16, 102, 122 }; 
byte gateway[] = { 10, 16, 0, 5 }; 
byte subnet[] = { 255, 255, 0, 0 }; 
EthernetServer server(80); 

String readString;



void setup(){
 pinMode(inPin, INPUT);
 pinMode(outPin, OUTPUT);

 //pinMode(led1, OUTPUT); 
  pinMode(led2, OUTPUT);
   pinMode(led3, OUTPUT);
 
 Ethernet.begin(mac, ip, gateway, subnet);
 server.begin();

 Serial.begin(9600);
 Serial.println("server LED test 1.0"); 
}



void loop ()
{
 loop2 ();
 loop1 ();
}






void loop1(){
 
 EthernetClient client = server.available();
 if (client) {
   while (client.connected()) {
     if (client.available()) {
       char c = client.read();

      
       if (readString.length() < 100) {

        
         readString += c;
        
       }

     
       if (c == '\n') {

         
         Serial.println(readString); 

         client.println("HTTP/1.1 200 OK"); 
         client.println("Content-Type: text/html");
         client.println();

         client.println("<HTML>");
         client.println("<HEAD>");
         client.println("<meta name='apple-mobile-web-app-capable' content='yes' />");
         client.println("<meta name='apple-mobile-web-app-status-bar-style' content='black-translucent' />");
         client.println("<link rel='stylesheet' type='text/css' href='http://homeautocss.net84.net/a.css' />");
         client.println("<TITLE>Ev Otomasyon</TITLE>");
         client.println("</HEAD>");
         client.println("<BODY>");
         client.println("<hr />");
         client.println("<hr />");
         client.println("<H1>Ev Otomasyon</H1>");
         client.println("<hr />");
         client.println("<hr />");
         client.println("
");
         
         
         
        client.println("--- Salon --- 

");
        client.println("<a href=\"/?lighton1\"\">..... Ac .....</a>");
        client.println("<a href=\"/?lightoff1\"\">Kapat</a>
"); 
        client.println("
");
        client.println("<hr />"); 
        client.println("
");
        
        client.println("--- Mutfak --- 

");
        client.println("<a href=\"/?lighton2\"\">..... Ac .....</a>");
        client.println("<a href=\"/?lightoff2\"\">Kapat</a>
"); 
        client.println("
");
        client.println("<hr />");   
        client.println("
"); 
       
        client.println("--- Koridor --- 

");
        client.println("<a href=\"/?lighton3\"\">..... Ac .....</a>");
        client.println("<a href=\"/?lightoff3\"\">Kapat</a>
"); 
        client.println("
");
        client.println("<hr />");   
        client.println("
");      

         client.println("</BODY>");
         client.println("</HTML>");

         delay(1);
         
        client.stop();
        
         if(readString.indexOf("?lighton1") >0)
        
             {digitalWrite(outPin, HIGH);    
             Serial.println("Led1 On");
             }
        if(readString.indexOf("?lightoff1") >0)
         
           {digitalWrite(outPin, LOW);   
             Serial.println("Led1 Off");
           }
      
       if(readString.indexOf("?lighton2") >0)
           {
             digitalWrite(led2, HIGH);   
             Serial.println("Led2 On");
           }
         
       if(readString.indexOf("?lightoff2")>0)
         
             {digitalWrite(led2, LOW); 
             Serial.println("Led2 Off");
           }  

       if(readString.indexOf("?lighton3") >0)
           {
             digitalWrite(led3, HIGH);    
             Serial.println("Led3 On");
           }
         
       if(readString.indexOf("?lightoff3")>0)
         
             {digitalWrite(led3, LOW);    
             Serial.println("Led3 Off");
           }
           
           
         
     //  delay(2000);
         readString="";
}
   }}}}
   
   
   void loop2(){
       reading = digitalRead(inPin);

 // if the input just went from LOW and HIGH and we've waited long enough
 // to ignore any noise on the circuit, toggle the output pin and remember
 // the time
 if (reading == HIGH && previous == LOW && millis() - time > debounce) {
   if (state == HIGH)
     state = LOW;
   else
     state = HIGH;

   time = millis();    
 }

 digitalWrite(outPin, state);

 previous = reading;
     
   }

You missed #7 below:

http://forum.arduino.cc/index.php/topic,148850.0.html