Read several parameters from HTTP GET request

My main goal is to read several parameters from an HTTP request to my arduino.
I am able to read just one piece of data (eg: However, when I try to read more than a variable (eg: I have problems.
The HTTP request to capture is of the following type:

Where data12=1 is a command and key=123456 is a key that my program should check.

My guess is that the problem is with the strcmp somehow, because I have tried debugging the problem usin serial.write and serial.print and the key that I get from the request appears to be the same one as the char* from the program.

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

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 177);
EthernetServer server(80);

const int msPersiana = 13700;

const int tubo1 = 5;
const int tubo2 = 6;
const int subirPersiana = 7;
const int bajarPersiana = 8;
const char* pwd_key = "&key=123456";

void setup()
  Ethernet.begin(mac, ip);
  Serial.print("server is at ");
  pinMode(tubo1, OUTPUT);
  pinMode(tubo2, OUTPUT);

void loop()
  EthernetClient client = server.available(); 
  if (client)
    Serial.println("new client");
    bool currentLineIsBlank = true;
    String cadena = "";
    while (client.connected()) 
      if (client.available()) 
        char c =;
        if (cadena.length()<50)
           // Buscar campo data
          int dataPosition = cadena.indexOf("data");
          int keyPosition = cadena.indexOf("&key");
          String command = cadena.substring(dataPosition, keyPosition);
          String key = cadena.substring(keyPosition);
          //if(strcmp("Hola", "Hola") != 0){
          //  Serial.println("Funciona");

          if (strcmp(key.c_str(), pwd_key) != 0){
          if (command == "data12=0" || command == "data1=0"){
            digitalWrite(tubo1, LOW);
          if (command == "data12=0" || command == "data2=0"){
            digitalWrite(tubo2, LOW);
          if (command == "data12=1" || command == "data1=1"){
            digitalWrite(tubo1, HIGH);
          if (command == "data12=1" || command == "data2=1"){
            digitalWrite(tubo2, HIGH);
        // Al recibir linea en blanco, servir página a cliente
        if (c == '\n' && currentLineIsBlank)
          client.println(F("<html>\n<head>\n<title>Smart Home</title>\n</head>\n"
          "<body>\n<H1>Alex Smart Home</H1>\n</body>\n</html>"));
          break; //Sale del Bucle while
        if (c == '\n') 
          currentLineIsBlank = true;
        else if (c != '\r') 
          currentLineIsBlank = false;

So as it can be seen the “key” parameter is a kind of password to allow the client connecting to the server or being kicked out.

I have not been able to run the program correctly using the query:

Which should match passwords and execute the command data12=1.

Thank you.

You should avoid using the String object and learn how to use C strings (nul terminated char arrays).

I'm guessing that your strcmp() is not equal and I'm guessing it is not equal because your variable key has a newline character '\n' at the end and the string you are testing against does not. It is a very common problem when parsing input (forgetting to remove the trailing newline).

You should also try printing out some debug statements when the strcmp() function returns non zero so you can see what's going on.

Have a look at the parse example in Serial Input Basics

It should not be too difficult to adapt it for your requirements.