# Ethernet Library Usage: Create a text entry and submit button

**URL:** <https://forum.arduino.cc/t/ethernet-library-usage-create-a-text-entry-and-submit-button/237518>\
**Category:** Programming\
**Created:** [June 1, 2014, 3:28pm UTC](https://forum.arduino.cc/t/ethernet-library-usage-create-a-text-entry-and-submit-button/237518 "2014-06-01T15:28:53Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![modsbyus](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@modsbyus](https://forum.arduino.cc/u/modsbyus)\
**Post date:** [June 1, 2014, 3:28pm UTC](https://forum.arduino.cc/t/ethernet-library-usage-create-a-text-entry-and-submit-button/237518/1 "2014-06-01T15:28:53Z")

</div>

I want to make a text entry and submit button so I can send a value to the arduino from the arduino served web page. Then store the submitted value in a variable for use. Can anyone point me in the right direction?

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [June 1, 2014, 3:30pm UTC](https://forum.arduino.cc/t/ethernet-library-usage-create-a-text-entry-and-submit-button/237518/2 "2014-06-01T15:30:21Z")

</div>

> Can anyone point me in the right direction?

> **[HTML Forms](https://www.w3schools.com/html/html_forms.asp)**
>
> W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.

---

<div class="post-metadata">

**Author:** ![modsbyus](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@modsbyus](https://forum.arduino.cc/u/modsbyus)\
**Post date:** [June 1, 2014, 3:38pm UTC](https://forum.arduino.cc/t/ethernet-library-usage-create-a-text-entry-and-submit-button/237518/3 "2014-06-01T15:38:49Z")

</div>

Thanks PaulS. That gets me to what I need in html side of it. How do I receive that data on the arduino side for storing in a variable?

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [June 1, 2014, 3:49pm UTC](https://forum.arduino.cc/t/ethernet-library-usage-create-a-text-entry-and-submit-button/237518/4 "2014-06-01T15:49:37Z")

</div>

> How do I receive that data on the arduino side for storing in a variable?

Have you looked at the Arduino-as-server example? Have you written ANY code?

---

<div class="post-metadata">

**Author:** ![modsbyus](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@modsbyus](https://forum.arduino.cc/u/modsbyus)\
**Post date:** [June 1, 2014, 4:50pm UTC](https://forum.arduino.cc/t/ethernet-library-usage-create-a-text-entry-and-submit-button/237518/5 "2014-06-01T16:50:46Z")

</div>

> PaulS:
> 
> > How do I receive that data on the arduino side for storing in a variable?
> 
> Have you looked at the Arduino-as-server example? Have you written ANY code?

I have looked at the example - webServer and ChatServer. I haven't written any code for this project. Right now I am trying to get a better understanding of how the Ethernet library works.  
I don't see any input from the webpage on the Webserver example. On the ChatServer example I see

```arduino
void loop() {
  // wait for a new client:
  EthernetClient client = server.available();

  // when the client sends the first byte, say hello:
  if (client) {
    if (!alreadyConnected) {
      // clead out the input buffer:
      client.flush();
      Serial.println("We have a new client");
      client.println("Hello, client!");
      alreadyConnected = true;
    }

    if (client.available() > 0) {
      // read the bytes incoming from the client:
      char thisChar = client.read();
      // echo the bytes back to the client:
      server.write(thisChar);
      // echo the bytes to the server as well:
      Serial.write(thisChar);
    }
  }
}

```

In an effort to understand what is going on here......

```arduino
void loop() {
  // wait for a new client:
  EthernetClient client = server.available();                    //not sure at all what this does.

   // when the client sends the first byte, say hello:    
  if (client) {                                                                                
    if (!alreadyConnected) {                                                  //if client is not connected
      // clear out the input buffer:                                       
      client.flush();                                                                      //clear the input buffer.. why are we clearing the buffer?
      Serial.println("We have a new client");                    //print in serial that a client is connected
      client.println("Hello, client!");                                      //say hi to the new client
      alreadyConnected = true;                                            //acknowledging a client is connected? 
    }                                                                         

    if (client.available() > 0) {                                //if there are more than 0 clients available 
      // read the bytes incoming from the client:
      char thisChar = client.read();                    //Store what client sends in thisChar
      // echo the bytes back to the client:       
      server.write(thisChar);                                //Repeat what was received 
      // echo the bytes to the server as well: 
      Serial.write(thisChar);                                //Display what is received
    }
  }
}

```

I think this is what I would need to receive from the webpage. Am I at least close?

```arduino
void loop() {
        char thisChar = client.read();
      // echo the bytes back to the client:
      server.write(thisChar);
      
  }

```

---

<div class="post-metadata">

**Author:** ![modsbyus](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@modsbyus](https://forum.arduino.cc/u/modsbyus)\
**Post date:** [June 1, 2014, 6:16pm UTC](https://forum.arduino.cc/t/ethernet-library-usage-create-a-text-entry-and-submit-button/237518/6 "2014-06-01T18:16:08Z")

</div>

Okay, So trying to make the text input.... I get this error.... I know I've formatted it wrong but I don't know how.

WebServer.ino: In function 'void loop()':  
WebServer:73: error: expected `)' before 'text'

```cpp
/*
  void loop() {
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          // output the value of each analog input pin
          client.println("<form>");
          client.println("Name: <input type="text" name="First Name">");
          client.println("</form>");
          client.println("</html>");
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
    Serial.println("client disconnected");
  }
}

```

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [June 1, 2014, 6:20pm UTC](https://forum.arduino.cc/t/ethernet-library-usage-create-a-text-entry-and-submit-button/237518/7 "2014-06-01T18:20:05Z")

</div>

```cpp
          client.println("Name: <input type="text" name="First Name">");

```

Double quotes that are to be part of the string need to be escaped. Otherwise, they mark the end of the string.

---

<div class="post-metadata">

**Author:** ![modsbyus](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@modsbyus](https://forum.arduino.cc/u/modsbyus)\
**Post date:** [June 1, 2014, 6:42pm UTC](https://forum.arduino.cc/t/ethernet-library-usage-create-a-text-entry-and-submit-button/237518/8 "2014-06-01T18:42:55Z")

</div>

What do you mean by "escaped"?

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [June 1, 2014, 7:09pm UTC](https://forum.arduino.cc/t/ethernet-library-usage-create-a-text-entry-and-submit-button/237518/9 "2014-06-01T19:09:28Z")

</div>

client.println("Name: \<input type=\</mark\>"text\</mark\>" name=\</mark\>"First Name\</mark\>"\>");

---

<div class="post-metadata">

**Author:** ![AmolGulhane07](https://avatars.discourse-cdn.com/v4/letter/a/edb3f5/32.png) [@AmolGulhane07](https://forum.arduino.cc/u/AmolGulhane07)\
**Post date:** [January 23, 2015, 10:53am UTC](https://forum.arduino.cc/t/ethernet-library-usage-create-a-text-entry-and-submit-button/237518/10 "2015-01-23T10:53:12Z")

</div>

kindly upload your arduino and HTML code.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 5, 2021, 8:42pm UTC](https://forum.arduino.cc/t/ethernet-library-usage-create-a-text-entry-and-submit-button/237518/11 "2021-05-05T20:42:45Z")

</div>

Closed on May 5, 2021, 8:42pm UTC


