Troubleshooting automatic roller blind

Hello arduino folks!

For some weeks I've been working with my Automatic roller blind project and in this "update" I've added an ethernet module (ENC28J60). Almost everything works fine, but I got some small problems. I will include an amateur schematic and the code further down.
my problems:

  1. Sometimes when I click on the "Upp"(this means up in swedish) button on the website it sometimes receives the up command several times so the roller blind won't stop go up.
  2. I tried to set the IP address static which I can switch on and off by the "#define STATIC 1" line, the third line in the code.
    This worked fine yesterday but now when I try to connect to it this morning it doesn't work, I have to automatically assign it an IP address and then it works. (The automatically assigned IP address wasn't the same as the static, it got a new one).

Is this something I can solve by altering the code? Thanks so much for the help!

I just have to mention that I have just altered a code that turns a LED on and off when the webbrowser requests the two different subpaths(?LED10=OFF and ?LED10=ON)

#include <EtherCard.h>
#include <Servo.h>
#define STATIC 1  // set to 1 to disable DHCP (adjust myip/gwip values below)

// mac address
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
// ethernet interface ip address
static byte myip[] = { 176,10,239,138 };
// gateway ip address
static byte gwip[] = { 176,10,236,1 };

// LED to control output
long upTime = 5000;
long downTime = 13500;
int ledPin10 = 2;
int servoPin = 9;
Servo EServo;
byte Ethernet::buffer[700];

char page[] PROGMEM =
"HTTP/1.0 503 Service Unavailable\r\n"
"Content-Type: text/html\r\n"
"Retry-After: 600\r\n"
"\r\n"
"<html>"
  "<head>"
  "<script>"
"function onFunction()"
"{"
"location.href='?LED10=ON'"
"}"
"function offFunction()"
"{"
"location.href='?LED10=OFF'"
"}"
"</script>"

  "<title>"
    "Erics automagiska rullgardinsdragare!"
  "</title></head>"
  "<body>"
    "<h3>Erics automagiska rullgardin</h3>"
    "<p><em>"
      "<p id='demo'>Tryck p&aring; en av knapparna!</p>"

"<button type='button' onclick='onFunction()'>Upp</button> 
"
"<button type='button' onclick='offFunction()'>Ner</button>"
    "</em></p>"
  "</body>"
"</html>"
;

void setup () {
  pinMode(ledPin10, OUTPUT);

  Serial.begin(9600);
  Serial.println("Trying to get an IP...");

  Serial.print("MAC: ");
  for (byte i = 0; i < 6; ++i) {
    Serial.print(mymac[i], HEX);
    if (i < 5)
      Serial.print(':');
  }
  Serial.println();
  
  if (ether.begin(sizeof Ethernet::buffer, mymac) == 0) 
    Serial.println( "Failed to access Ethernet controller");

#if STATIC
  Serial.println( "Getting static IP.");
  if (!ether.staticSetup(myip, gwip)){
    Serial.println( "could not get a static IP");
    blinkLed();     // blink forever to indicate a problem
  }
#else

  Serial.println("Setting up DHCP");
  if (!ether.dhcpSetup()){
    Serial.println( "DHCP failed");
    blinkLed();     // blink forever to indicate a problem
  }
#endif
  
  ether.printIp("My IP: ", ether.myip);
  ether.printIp("Netmask: ", ether.mymask);
  ether.printIp("GW IP: ", ether.gwip);
  ether.printIp("DNS IP: ", ether.dnsip);
}

void loop () {
 
  word len = ether.packetReceive();
  word pos = ether.packetLoop(len);

  // IF LED10=ON turn it ON
  if(strstr((char *)Ethernet::buffer + pos, "GET /?LED10=ON") != 0) {
      Serial.println("Received ON command");
      digitalWrite(ledPin10, HIGH);
      EServo.attach(servoPin);
       EServo.write(178);
       delay(upTime);
         digitalWrite(ledPin10, LOW);
       EServo.detach();
    }

    // IF LED10=OFF turn it OFF  
    if(strstr((char *)Ethernet::buffer + pos, "GET /?LED10=OFF") != 0) {
      Serial.println("Received OFF command");
      digitalWrite(ledPin10, HIGH);
  EServo.attach(servoPin);
       EServo.write(2);
       delay(downTime);
        digitalWrite(ledPin10, LOW);
       EServo.detach();
    }

    // show some data to the user
    memcpy_P(ether.tcpOffset(), page, sizeof page);
    ether.httpServerReply(sizeof page - 1);
}

void blinkLed(){
  while (true){
    digitalWrite(ledPin10, HIGH);
    delay(500);
    digitalWrite(ledPin10, LOW);
    delay(500);
  }
}

Suggest you print out the whole of the incoming HTTP request each time to see what you're actually getting. It may be that your web page is generating extra HTTP requests, for example browsers routinely retry requests for a favicon and perhaps you're mis-recognising that.

I'm not familiar with the EtherCard library - is your use of packetReceive(), packetLoop() and strstr() a conventional way to extract the incoming URL? Your use of the HTTP 503/Service Unavailable status code on every page is also new to me. What's that intended to achieve?

PeterH:
Suggest you print out the whole of the incoming HTTP request each time to see what you're actually getting.

That sounds like a good idea but I'm not sure of how to do that, print out the whole incoming HTTP request?

PeterH:
It may be that your web page is generating extra HTTP requests, for example browsers routinely retry requests for a favicon and perhaps you're mis-recognising that.

So you're saying that the internet browser might send several requests depsite the fact that I just clicked on my button once?

PeterH:
I'm not familiar with the EtherCard library - is your use of packetReceive(), packetLoop() and strstr() a conventional way to extract the incoming URL? Your use of the HTTP 503/Service Unavailable status code on every page is also new to me. What's that intended to achieve?

I'm a real beginner on this Arduino-Internet thing so I can't really explain why I use it. I have just found the code and changed it so it might work, anybody out there who can explain how I should do this?
Or should I use another library instead of ethercard?
Thanks guys!

Archelon:
So you're saying that the internet browser might send several requests depsite the fact that I just clicked on my button once?

Yes, absolutely - almost every browser will do that.

PeterH:

Archelon:
So you're saying that the internet browser might send several requests depsite the fact that I just clicked on my button once?

Yes, absolutely - almost every browser will do that.

Alright, I will try to change to the "UIPEthernet" library. That gives me more example codes and tutorials out there to try 'cause I can use most of the codes that uses the Ethernet.h library.