decoding a GET response from an HTML form

Very new at Arduino and C.
I have written a sketch to control a water sprinkling system using an Arduino UNO, Ethernet and relay shields. I have made a simple HTML website containing 9 pages of which 7 of these pages represent each day of the week. Each "DAY" page has drop downs to set the hours and minute for on and off times with a hidden field to ID the day name (actually number). I am using the GET type forms so i can see the data in the URL. The data I get back is "?D=1&OnH=13&OnM=15&OfH=13&OfM=25", Great so far!

The problem, how to parse it out and assign variables to the five elements?

D=X X to equal 1= Sunday ... 7= Saturday
OnH=X or XX Value returned 0=midnight ...23=11PM (1 or 2 chars returned depending on the time)
OnM=X or XX Value returned 0 ... 55 Minutes in 5 min increments (1 or 2 chars returned depending on the time)
OfH=X or XX Value returned 0=midnight ...23=11PM (1 or 2 chars returned depending on the time)
OfM=X or XX Value returned 0 ... 55 Minutes in 5 min increments (1 or 2 chars returned depending on the time)

I am looking at changing the delimiter to "&" and looping to place the form data into variables. Got thinking with web form data is there a simpler way?

Possibly a "#include Web_Form_Decode" that does this already???

Here is web server code that parses two variables, but it should be no problem to do 5.
http://playground.arduino.cc/Code/WebServerST

Thanks for the replies, the Web Server ST contains the functionality im after :slight_smile:

I do have 2 questions about modifying the code to suit my needs.

#1. When I enter in a number value with a proceeding "0" into one of the webform text boxes it gets stripped away once its saved to thevariable and displayed in the serial monitor. For instance, 0640 becomes just 630. Since I will be using it to enter in a 24 hour time value, the "0" is required. I cannot tell which part of the code is causing the "0" to be removed, can you advise how I can modify the code to prevent this from happening?

#2. If I want to make some of the web forms text fields save Strings instead of INTs would I just need to declare the variables which are being used to store these values at Strings instead of INTs? Or is it more complicated that that?

Once again, thank you for your time!

For instance, 0640 becomes just 630. Since I will be using it to enter in a 24 hour time value, the "0" is required. I cannot tell which part of the code is causing the "0" to be removed, can you advise how I can modify the code to prevent this from happening?

Why is the leading 0 required? What code are you using to parse the data, and what clock-setting code expects time values as strings?

If I want to make some of the web forms text fields save Strings instead of INTs would I just need to declare the variables which are being used to store these values at Strings instead of INTs?

All web form text fields deal with strings. It is the application that uses the text field contents that cares whether the string represents a numeric value, or not.

#1. When I enter in a number value with a proceeding "0" into one of the webform text boxes it gets stripped away once its saved to thevariable and displayed in the serial monitor.

That is the way you are displaying it, not the way it is stored. If you want a specific numeric format, like leading zeros, you need to use sprintf().

From memory, this should display the leading zeros.

char buffer[8];
sprintf(buffer,"%04u",r);
Serial.println(buffer);