LED Light not toggling

Hi
I have merged to sketches I found on the internet a http post and a toggle switch. Both work perfectly fine individually.

The toggle switch makes a http post to my webserrver, this is working perfectly fine but for some reason the LED light that is supposed to turn on/off isn't. I have loaded the original sketch back in place and the led toggles.

I use the same if statement to call the http post as toggle the LED. I can't see whats wrong I was hoping someone with more knowledge than myself, not hard learning very much as I go, would be able to have a look and point out my silly mistake.

thanks jasemilly

//zoomkat 4-04-12
//simple client test
//for use with IDE 1.0
//open serial monitor and send an e to test
//for use with W5100 based ethernet shields
//note that the below bug fix may be required
// http://code.google.com/p/arduino/issues/detail?id=605
//the arduino lan IP address { 192, 168, 0, 102 } may need
//to be modified modified to work with your router.

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


//toggle variables
int inPin = 2;         // the number of the input pin
int outPin = 13;       // the number of the output pin

int LDR_Pin = A0; //analog pin 

int state = HIGH;      // the current state of the output pin
int reading;           // the current reading from the input pin
int previous = LOW;    // the previous reading from the input pin

// the follow variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long time = 0;         // the last time the output pin was toggled
long debounce = 200;   // the debounce time, increase if the output flickers



//network variables
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 0, 50 }; // ip in lan assigned to arduino
byte gateway[] = { 192, 168, 0, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
byte myserver[] = { 192, 168, 0, 34 }; // zoomkat web page server IP address
EthernetClient client;
//////////////////////

void setup(){

  //Ethernet.begin(mac, ip);
  Ethernet.begin(mac, ip, gateway, gateway, subnet);
  Serial.begin(9600);
  Serial.println("Better client test 4/04/12"); // so I can keep track of what is loaded
  Serial.println("Send an e in serial monitor to test"); // what to do to test
}

void loop(){
 
 
   reading = digitalRead(inPin);
 
  // check for serial input
  if (Serial.available() > 0) //if something in serial buffer
  {
    byte inChar; // sets inChar as a byte
    inChar = Serial.read(); //gets byte from buffer
    if(inChar == 'e') // checks to see byte is an e
    {
      sendPOST(); // call sendPOST function below when byte is an e
    }
  } 

 

  // 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) {
     Serial.println("button press");//test
    if (state == HIGH){
      state = LOW;
      sendPOST();
    }
    else
     {
      state = HIGH;
      sendPOST();
      time = millis();
     }    
  
}

digitalWrite(outPin, state);
previous = reading;
  
}

void sendPOST() //client function to send/receive POST request data.
{
  
  String PostData="url=http://192.168.0.34:81/tenHsServer/tenHsServer.aspx?t=ab&f=ToggleDevice&d=E3";
  
  if (client.connect(myserver, 80)) {      
    Serial.println("connected");
    client.println("POST /WestCroft/urlencode.php HTTP/1.1");
    client.println("Host:  192.168.0.34");
    client.println("User-Agent: Arduino/1.0");
    client.println("Connection: close");
    client.println("Content-Type: application/x-www-form-urlencoded;");
    client.print("Content-Length: ");
    client.println(PostData.length());
    client.println();
    client.println(PostData); 
  }
  else {
    Serial.println("connection failed"); //error message if no client connect
    Serial.println();
  }
  
  Serial.println();
  Serial.println("disconnecting.");
  Serial.println("==================");
  Serial.println();
  client.stop(); //stop client

}

outPin is not defined as an output.
Could that be a problem I wonder, because they default to being inputs otherwise.

#include <Ethernet.h>


//toggle variables
int inPin = 2;         // the number of the input pin
int outPin = 13;       // the number of the output pin

The first and last statements here do not belong in the same sketch. The Ethernet shield communicates with the Arduino using SPI, which, for the 328-based Arduinos means pins 11, 12, and 13.

Thanks guys defined the output properly and it worked like a charm!!

I checked my code several times and never spotted!!