HTML Server Web Pin Control

The problem was what both of you pointed out. Firefox was requesting a favicon.ico directly after I made my on or off request so there was a request where the program saw 'on' from favicON.ico and thought it needed to turn the light on right after I clicked on or off which is why it was always going back on.

Here is a generalized version of the code I modified from the program that zoomkat so generously shared with me:

//zoomkat 4-1-12 (modified by durkinnj 12-20-12)
//simple pin control through html
//for use with IDE 1.0
//open serial monitor to see what the arduino receives
//use the \ slash to escape the " in the html, or use ' instead of " 
//address will look like http://192.168.0.80 when submitted
//for use with W5100 based ethernet shields
//modified to control an LED (on pin 5) but can be applied to a number of 
//applications which displays updated status of LED etc.

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

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 0, 80 }; // ip in lan // this may be changed if necessary
//byte gateway[] = { 192, 168, 1, 1 }; // internet access via router //not needed
//byte subnet[] = { 255, 255, 255, 0 }; //subnet mask //not needed
EthernetServer server(80); //server port
boolean led = false; //led status
String readString; 

//////////////////////

void setup(){

  pinMode(5, OUTPUT); //pin selected to control
  //start Ethernet
  Ethernet.begin(mac, ip);
  server.begin();

  //enable serial data print 
  Serial.begin(9600); 
  Serial.println("Server/ pin 5 test 1.0"); // so I can keep track of what is loaded
}

void loop(){
  // Create a client connection
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();

        //read char by char HTTP request
        if (readString.length() < 100) {

          //store characters to string 
          readString += c; 
          //Serial.print(c);
        } 

        //if HTTP request has ended
        if (c == '\n') {

          ///////////////////// control arduino pin
          if(readString.indexOf("ledon") >0)//checks for on
          {
            digitalWrite(5, HIGH);    // set pin 5 high
            led = true;
            Serial.println("Led On");
          }
          if(readString.indexOf("ledoff") >0)//checks for off
          {
            digitalWrite(5, LOW);    // set pin 5 low
            led = false;
            Serial.println("Led Off");
          }
          
          ///////////////
          Serial.println(readString); //print to serial monitor for debuging 

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

          client.println("<HTML>");
          client.println("<HEAD>");
          client.println("<META HTTP-EQUIV='refresh' CONTENT='5'>");
          client.println("<TITLE>CARduino</TITLE>");
          client.println("</HEAD>");
          client.println("<BODY>");
          client.println("<h1 style='text-align:center;font-size:70px;'>LED Control Center
</h1>");
          if(led == false){
          client.println("<div style='padding-left:25px;font-size:50px;display:inline;'>LED Status: OFF</div><a href='/?ledon'><div style='font-size:60px;display:inline;padding-left:100px;'><button type='submit'><div style='font-size:60px;'>Turn On</div></button></div></a>"); }
          else {
          client.println("<div style='padding-left:25px;font-size:50px;display:inline;'>LED Status: ON&nbsp;</div><a href='/?ledoff'><div style='font-size:60px;display:inline;padding-left:100px;'><button type='submit'><div style='font-size:60px;'>Turn Off</div></button></div></a>"); }

          client.println("</BODY>");
          client.println("</HTML>");
 
          delay(1);
          //stopping client
          client.stop();
          
          //clearing string for next read
          readString="";

        }
      }
    }
  }
}