controlling 2 servos using html , only one servo fully functional

hello all , for a project Im working on at the moment i'm looking to control a few servos via a web page that can be accessed from anywhere.with the example sketch I found the Arduino board serves up a page with 5 buttons , 2 control an LED , one off and one on , and the other 3 have the ability to turn the Arduino to positions 0,90 and 180. I tried to code for an a additional servo and found that the controls on the web page duplicated with no problems but that for the additional servo only 1 button would effect the servo. after pressing one button it would go to the designated position and then hum and become unresponsive.

I'm using and arduino uno and a compatible ethernet shield.
heres the sketch

#include <SPI.h>
#include <Ethernet.h> add libraries for servo and ethernet

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; my mac address and arduinos ip
byte ip[] =  { 192,168,0,8 };

const int MAX_PAGENAME_LEN = 8; // max characters in page name
char buffer[MAX_PAGENAME_LEN+1]; // additional character for terminating null

EthernetServer server(8081);

// Servo Library and setup
#include <Servo.h>
Servo myservo ;  // create servo object to control a servo
int servo = 6;    //Define what pin the servo is on
Servo myservo2; , servo number 2 here
int servo2=3;

void setup()
{
  Serial.begin(9600); //Start serial port for debugging
  myservo.attach(servo);
myservo2.attach(servo2);   // attaches the servo on pin 6 to the servo object
  Ethernet.begin(mac, ip);
  server.begin();
  delay(2000);
}

void loop()
{

  EthernetClient client = server.available();
  if (client) {
    int type = 0;
    while (client.connected()) {
        if (client.available()) {
        // GET, POST, or HEAD
        memset(buffer,0, sizeof(buffer)); // clear the buffer
        if(client.readBytesUntil('/', buffer,sizeof(buffer))){
          if(strcmp(buffer,"POST ") == 0){
            client.find("\n\r"); // skip to the body
            // find string starting with "pin", stop on first blank line
            // the POST parameters expected in the form pinDx=Y
            // where x is the pin number and Y is 0 for LOW and 1 for HIGH
            while(client.findUntil("pinD", "\n\r")){
              int pin = client.parseInt();       // the pin number
              int val = client.parseInt(); 
              int val2 = client.parseInt();       // 0 or 1
              pinMode(pin, OUTPUT);
              if(pin == 9){
                digitalWrite(pin , val  );
              }
              Serial.println(val);
              if(pin == 6){
                myservo.write(val);
              }
            Serial.println(val2);
              if(pin == 3){
                myservo2.write(val2);
not entirely sure about the above code , probably my problem. just tried to replicated what I saw as being the logic driving the first servo
          
        }
            }
            
            

      
          }
          sendHeader(client,"Post example");
          //Control of Light
          //create HTML button to control pin 9
          client.println("<h2><font color=#f6a343>IoT - Servo and LED</h2>");
          client.print(
          "<form action='/' method='POST'><p><input type='hidden' name='pinD9'");
          client.println(" value='0'><input type='submit' value='Light Off'/></form>");
          //create HTML button to turn on pin 9
          client.print(
          "<form action='/' method='POST'><p><input type='hidden' name='pinD9'");
          client.print(" value='1'><input type='submit' value='Light On'/></form>");

          //Control of Servo
          //Turn Right
          client.print(
          "<form action='/' method='POST'><p><input type='hidden' name='pinD6'"); form action sends data from the server , the board to the client , the web page. here the pinD is specified. little hazy here as the term value seems to spring from nowhere , this is not the same as the int val specified earlier in the sketch? client.print sends html code to the browser.
          client.println(" value='0'><input type='submit' value='Servo Right'/></form>");
          //Turn Left
          client.print(
          "<form action='/' method='POST'><p><input type='hidden' name='pinD6'");
          client.print(" value='180'><input type='submit' value='Servo Left'/></form>");
          //Stop
          client.print(
          "<form action='/' method='POST'><p><input type='hidden' name='pinD6'");
          client.print(" value='90'><input type='submit' value='Servo Stop'/></form>");
          
          
         client.print(
          "<form action='/' method='POST'><p><input type='hidden' name='pinD3'"); I replicated the above and specified the pin the other servo was attached to , pin 3
          client.println(" value='0'><input type='submit' value='Servo Right'/></form>");
          //Turn Left
          client.print(
          "<form action='/' method='POST'><p><input type='hidden' name='pinD3'");
          client.print(" value='180'><input type='submit' value='Servo Left'/></form>");
          //Stop
          client.print(
          "<form action='/' method='POST'><p><input type='hidden' name='pinD3'");
          client.print(" value='90'><input type='submit' value='Servonob Stop'/></form>");
        
          //Create webcam feed
          //client.print("<img name=""FoscamCamera"" src=""http://67.168.78.50:1026/videostream.cgi?user=peon&pwd=noob"" width=""480"" height=""360"" alt=""Live Feed"" style=""background-color: #009999"" />"); not using this section
        
        
          client.println("</body></html>"); I think html requires a body for every page , hence this empty tag.
        

        
          client.stop();
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    client.stop();
  }
}

void sendHeader(EthernetClient client, char *title)
{
  // send a standard http response header
  client.println("HTTP/1.1 200 OK");
  client.println("Content-Type: text/html");
  client.println();
  client.print("<html><head><title>");
  client.print(title);
  client.println("</title><body>");
}

I'm not quite sure what my problem is anyone who could tell me would be much appreciated

My guess is that you ran out of memory. Use the F() macro to keep all those (huge) string literals out of SRAM.

client.println(F("

IoT - Servo and LED

"));

Also consider whether you REALLY need to specify color for the text. The form you serve up has multiple items with the same name. That makes handling the GET/POST requests that are generated difficult. Every item should have a unique name.

          client.println("</body></html>"); I think html requires a body for every page , hence this empty tag.

It does. Comments need // in front of them, though. And, that isn't an empty tag. It's two close tags, to close the body and the page.

thanks paul , ill try that out . do you think running 6 plus servo's and a dc motor , will cause memory problems even if I use the f macro?

also i definitely do not need to specify a font colour
thanks
sam

do you think running 6 plus servo's and a dc motor , will cause memory problems even if I use the f macro?

Without all those string literals clogging up SRAM, you should have plenty of memory for controlling 6 servos and a motor. As long as you don't fall into the String trap.

Surely that isn't your actual code? I can't believe it would compile. You need to post code that compiles and demonstrates the problem.

How are the servos powered?

well I added some of the comments in once the text was pasted in this forum so I didn't use the // function as I was out of the IDE. is it that what you mean?

there being powered just through the 5v port on the arduino which is pinned to the positive rail on the breadboard. I don't think it's a power issue though as I wrote a little programme to make them both go back and forth synchronously and there was no issue.

secondly I tried swapping the pins round and found that it was always the servo at pin 3 that would exhibit the faulty behaviour.

cheers
sam

ah thanks again , I just googled the string trap ? is it something I should be really worried about ?

cheers
sam