Webserver Editing Option on arduino

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
AJITnayak
 
Posts: 5
Joined: Fri Dec 20, 2013 4:07 am

Webserver Editing Option on arduino

Post by AJITnayak »

web.JPG
web.JPG (63.49 KiB) Viewed 185 times
web.JPG
web.JPG (63.49 KiB) Viewed 185 times
Dear all,
I am new on webserver application development. I am developing code where i can receive data from client and being changed in webserver. for example changing of date 12-12-2012 to 12-4-2014. I have pasted my code below. Here i have kept option to edit value . if edit option selected you can change date and time else see current date and time

Code: Select all


#include <SPI.h>
#include <Ethernet.h>
static int local_day=12;
static int local_month;
static int local_year;
static int local_s;
static int local_h;
static int local_m;
byte mac[] = { 
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 
  192, 168,1, 120 };  
EthernetServer server(80);
void setup()
{
  Serial.begin(9600);
  Ethernet.begin(mac, ip);
  server.begin();
}
void loop()
{
  Ethernet_Control();
}
void Ethernet_Control()
{
  EthernetClient client = server.available();
  // detect if current is the first line
  boolean current_line_is_first = true;
char c;
  if (client) {
    // an http request ends with a blank line
    boolean current_line_is_blank = true;
    while (client.connected()) {
      if (client.available()) {
        c = client.read();

        // if we've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so we can send a reply
        if (c == '\n' && current_line_is_blank) {
         
          // send a standard http response header
          
        
          client.println(F("HTTP/1.1 200 OK"));
          client.println(F("Content-Type: text/html"));
          client.println();
         /* client.println("<input type=\"checkbox\" name=\"EDIT\" value=\"2\" \
                      onclick=\"submit();\" checked>EDIT");*/
          int date;
          client.print(" <font> <color=blue> DD: <input type=text name=01 value=");
          date=client.read();
          Serial.println(date);
          //client.println(local_day);
          client.print(" <font> <color=blue> month: <input type=text name=01 value=");
          client.println(local_month);
          client.print(" <font> <color=blue> year: <input type=text name=01 value=");
          client.println(local_year);
          client.print(" <font> <color=blue> hour: <input type=text name=01 value=");
          client.println(local_h);
          client.print(" <font> <color=blue> min: <input type=text name=01 value=");
          client.println(local_m);
          client.print(" <font> <color=blue> sec: <input type=text name=01 value=");
          client.println(local_s);
          client.println("");
           client.println(F("</form><br />"));
           client.println(F("<button name=d value=1 type=submit style=height:30px;width:50px>OK</button>"));
          client.println("<p>NOTE: This page will automatically refresh every 5 seconds.</p></center>");
          
             
          
          client.println(F("<center><p><h5>Web application  V1.0</h5></p><center><hr><br />"));
          client.print(F("<p><h5>DATE: = <font color=indigo>"));
          client.print(local_day);
          client.print("/");
          client.print(local_month);
          client.print("/");
          client.print(local_year); 
          client.println("</font></h5></p>");
          client.print(F("<p><h5>TIME: = <font color=indigo>"));
          client.print(local_h);
          client.print(":");
          client.print(local_m);
          client.print(":");
          client.print(local_s);
    
          

          break;
        }

        if (c == '\n') {
          // we're starting a new line

          current_line_is_blank = true;
        } 
        else if (c != '\r') {
          // we've gotten a character on the current line
          current_line_is_blank = false;
        }
      }
     
    }
  delay(1);
  client.stop();  
 
}
}



User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Webserver Editing Option on arduino

Post by adafruit_support_mike »

Interesting.. thanks for posting it!

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”