Need help with some logic in my sketch.

I read that about the loops 6 times. I don't know if the website directly died quicker because of this but the code I copied had 3 so I changed it back to 3. It works so I'm not too worried about it.

Dustin:
I thought because I had 6 states (3 on 3 off) i needed to change it to 6 (default was 3). I changed it to loop once but then the website died after pushing a few buttons. It's set at 3 now and it's doing pretty well. Here's the updated code:

#include <WiServer.h>

#include <string.h>

#define WIRELESS_MODE_INFRA 1
#define WIRELESS_MODE_ADHOC 2

#define ledPin1 5
#define ledPin2 6
#define ledPin3 9

// Wireless configuration parameters ----------------------------------------
unsigned char local_ip[]    = {192,168,1,225};   // IP address of WiShield
unsigned char gateway_ip[]  = {192,168,1,1};   // router or gateway IP address
unsigned char subnet_mask[] = {255,255,255,0}; // subnet mask for the local network
const prog_char ssid[] PROGMEM     = {"The Tardis"};   // max 32 bytes
unsigned char security_type = 3;  // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2

// WPA/WPA2 passphrase
const prog_char security_passphrase[] PROGMEM = {"biggerontheinside"}; // max 64 characters

// WEP 128-bit keys
// sample HEX keys
prog_uchar wep_keys[] PROGMEM = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, // Key 0
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 1
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 2
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Key 3
};

// setup the wireless mode; infrastructure - connect to AP; adhoc - connect to another WiFi device
#define WIRELESS_MODE_INFRA 1
#define WIRELESS_MODE_ADHOC 2
unsigned char wireless_mode = WIRELESS_MODE_INFRA;
unsigned char ssid_len;
unsigned char security_passphrase_len;

// Webserver static content ------------------------------------------------
const prog_char wbHtmlOpen[] PROGMEM = {""};
const prog_char wbHeadOpen[] PROGMEM = {""};
const prog_char wbTitle[] PROGMEM = {"Door Opener"};
const prog_char wbMetaRefresh[] PROGMEM = {""};
const prog_char wbHeadClose[] PROGMEM = {""};
const prog_char wbBodyOpen[] PROGMEM = {""};
const prog_char wbDoor1Open[] PROGMEM = {"

Door  1 Is Open

"};
const prog_char wbDoor1Closed[] PROGMEM = {"

Door 1 Is Closed

"};
const prog_char wbDoor2Open[] PROGMEM = {"

Door 2 Is Open

"};
const prog_char  wbDoor2Closed[] PROGMEM = {"

Door 2 Is Closed

"};
const prog_char wbDoor3Open[] PROGMEM = {"

Door 3 Is Open

"};
const prog_char wbDoor3Closed[] PROGMEM = {"

Door 3 Is Closed

"};
const prog_char wbDivPatterns[] PROGMEM = {"GARAGE DOOR OPENER\n

"};
const prog_char wbDivPatterns2[] PROGMEM = {"<input type="submit" onclick="location='/?LED1 '" value="Button 1 On">
<input type="submit" onclick="location='/?LED2 '" value="Button 2 On">
<input type="submit" onclick="location='/?LED3 '" value="Button 3 On">

"};
const prog_char wbDivPatterns3[] PROGMEM = {"<input type="submit" onclick="location='/?LED4 '" value="Button 1 Off">
<input type="submit" onclick="location='/?LED5 '" value="Button 2 Off">
<input type="submit" onclick="location='/?LED6 '" value="Button 3 Off">
"};
const prog_char wbBodyClose[] PROGMEM = {""};
const prog_char wbHtmlClose[] PROGMEM = {""};

char ledChange;
char stateCounter;
boolean door1closed;
boolean door2closed;
boolean door3closed;
// Methods ------------------------------------------------------------------

boolean sendPage(char* URL) {

if(strncmp(URL, "/?LED", 5) == 0)
{
  ledChange = (int)(URL[5]) - 48;
  for (stateCounter = 0; stateCounter <3; stateCounter++)
  {
    if      ( ledChange == 1 )  { digitalWrite(ledPin1, HIGH); door1closed = false; }
    else if ( ledChange == 2 )  { digitalWrite(ledPin2, HIGH); door2closed = false; }
    else if ( ledChange == 3 )  { digitalWrite(ledPin3, HIGH); door3closed = false; }
    else if ( ledChange == 4 )  { digitalWrite(ledPin1,  LOW); door1closed = true;  }
    else if ( ledChange == 5 )  { digitalWrite(ledPin2,  LOW); door2closed = true;  }
    else if ( ledChange == 6 )  { digitalWrite(ledPin3,  LOW); door3closed = true;  }
}
    WiServer.print("");
    return true;
}

WiServer.println_P(wbHtmlOpen);
  WiServer.println_P(wbHeadOpen);
  WiServer.println_P(wbTitle);
  WiServer.println_P(wbMetaRefresh);
  WiServer.println_P(wbHeadClose);
  WiServer.println_P(wbBodyOpen);
  WiServer.println_P(wbDivPatterns);
  WiServer.println_P(wbDivPatterns2);
  WiServer.println_P(wbDivPatterns3);
  if ( door1closed == false ) { WiServer.println_P(wbDoor1Open);  }
  if ( door1closed == true  ) { WiServer.println_P(wbDoor1Closed);}
  if ( door2closed == false ) { WiServer.println_P(wbDoor2Open);  }
  if ( door2closed == true  ) { WiServer.println_P(wbDoor2Closed);}
  if ( door3closed == false ) { WiServer.println_P(wbDoor3Open);  }
  if ( door3closed == true  ) { WiServer.println_P(wbDoor3Closed);}
  WiServer.println_P(wbBodyClose);
  WiServer.println_P(wbHtmlClose);
  return true;
}

void setup() {
//setup leds
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
WiServer.init(sendPage);
}

void loop() {
   WiServer.server_task();
   delay(100);
}