Carpark entry counter

thanks people!, I now have this working(as far as code is concerned)
now, I have a hardware issue :frowning:

ok, i have a tactile switch with 2k2, pulldown resistor attached to D2, and another wired the same on D3,
there is a yellow led indicator attached to pin D5, red to pin D7, and green to D9.
now when i press switch 1, pin 5 lights the yellow LED
when i press switch two, pin 7 lights the red LED
when i hold one switch, and press the other, the code deciphers which was the first to trigger, modifies the counter(for total entries/exits) and pin 9 lights the green LED
these result are mirrored to the web server which can be viewed from a browser. until......

THE PROBLEM
when i press both buttons at once, the ethernet portion of the board drops out.
code is as follows:::

#include <SPI.h>
#include <Ethernet.h>
// For MEGA2560 with IEsheild v1.01 only
// #include <enc28j60.h>
// #include <ethershield>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,100);
const int IRTrigger1 = 2;     // the number of the pin used to read IR beam status
const int IRTrigger2 = 3;
const int CounterChange =  9;      // the number of the LED pin
const int IR1Triggered = 7;   // to show beam one is broken
const int IR2Triggered = 5;  // to show beam two is broken
// variables will change:
int IRState1 = 0;         // variable for reading the pushbutton status
int IRState2 = 0;
int totalcars =0;
int IRvalue1 = 0;
int IRvalue2 = 0;
int entering = 0;
int leaving = 0;
int webserver();
// Initialize the Ethernet server library
// with the IP address and port you want to use 
// (port 80 is default for HTTP):
EthernetServer server(80);

void setup() {

  // initialize the LED pin as an output:
  pinMode(CounterChange, OUTPUT);      
  // initialize the pushbutton pin as an input:
  pinMode(IRTrigger1, INPUT);     
  pinMode(IRTrigger2, INPUT); 
  pinMode(IR1Triggered, OUTPUT);
  pinMode(IR2Triggered, OUTPUT);
  Serial.begin(9600);
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
}

void loop(){
  
   EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    webserver();}
  // read the state of the pushbutton value:
  IRState1 = digitalRead(IRTrigger1);
  IRState2 = digitalRead(IRTrigger2);

    
     Serial.print("IRvalue1= ");
     Serial.println(IRState1);
     Serial.print("IRvalue2= ");
     Serial.println(IRState2);
     Serial.println(" ");
     Serial.println(" ");
if (IRState1 >0){
     IRvalue1=1; digitalWrite(IR1Triggered, HIGH);
     Serial.print("IRvalue1= ");
     Serial.println(IRvalue1);}
else digitalWrite(IR1Triggered,LOW);
if (IRState2 >0){
     IRvalue2=1;digitalWrite(IR2Triggered, HIGH);
     Serial.print("IRvalue2= ");
     Serial.println(IRvalue2);}
else digitalWrite(IR2Triggered,LOW);

if(IRState1 > IRState2){
  entering = 1;} else if (IRState2 > IRState1){
     leaving=1;}
  
if ((IRState1 + IRState2) ==2){
      if (entering == 1){
     totalcars = totalcars + 1;
     digitalWrite(CounterChange, HIGH);
     delay(1000);
     digitalWrite(CounterChange, LOW); }
     else if (leaving == 1){
    totalcars = totalcars - 1;
     digitalWrite(CounterChange, HIGH);
     delay(1000);
     digitalWrite(CounterChange, LOW); 
     }
entering=0; // reset everything
leaving=0;
IRState1=0;
IRState2=0;
}
}
int webserver(){

   EthernetClient client = server.available();
 boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) 
      //{
        char c = client.read();
   //   Serial.write(c);
       
        client.println("
"); 
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
   //   if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connnection: close");
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
                    // add a meta refresh tag, so the browser pulls again every 5 seconds:
          client.println("<meta http-equiv=\"refresh\" content=\"5\">");
          // output the value of each Digital input pin
          
             client.println("
");
            client.print("Beam 1 is ");
            client.println(IRState1);
             client.println("
");
            client.print("Beam 2 is ");
            client.print(IRState2);
            client.println("
");
     client.print("Total cars in carpark is ");      
     client.println(totalcars);
    //      }
          client.println("</html>");
          
          break;
        }
    //  if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
   //     } 
   //   else if (c != '\r') {
          // you've gotten a character on the current line
        currentLineIsBlank = false;
          // give the web browser time to receive the data
    delay(5);  
   //   }
    delay(5000);
     //}
   //close the connection:
    client.stop();
   Serial.println("client disonnected");  
  }
//}

sorry to be such a pain, any help is muchos appreciado