Webserver ENC28j60 showing water level sensor status

Hello friends,
This is my first post, i’m working with Arduino for a while, and created a project to check the oil level of a energy generator (sorry if its wrong, but i don’t know exactly how to translate this from my native language).
The point is, i’m trying to make a rev. 2. The first one showed just the result of 1 sensor (on and off)… Now i have to show on that page the results of 3 sensors.
I’m using this kind o sensor (http://ecx.images-amazon.com/images/I/41aijfptgnL.SY300.jpg), and a Arduino Uno.
My actual code is:

#include <EtherCard.h>

#define STATIC 1  //Desativa DHCP

#if STATIC
static byte myip[] = { 192, 168, 10, 98 };
static byte gwip[] = { 192, 168, 10, 101 };
#endif

static byte mymac[] = { 0x74, 0x69, 0x69, 0x2D, 0x30, 0x31 };

byte Ethernet::buffer[500]; // tcp/ip send and receive buffer

BufferFiller bfill;

int sensor = 3;
int vrd = 6;
int vrm = 7;

void setup() {
  Serial.begin(57600);
  Serial.println("\n[Iniciando...]");
  pinMode(sensor, INPUT);
  pinMode(vrd, OUTPUT);
  pinMode(vrm, OUTPUT);

  if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
    Serial.println( "Failed to access Ethernet controller");
#if STATIC
  ether.staticSetup(myip, gwip);
#else
  if (!ether.dhcpSetup())
    Serial.println("DHCP failed");
#endif

  ether.printIp("IP:  ", ether.myip);
  ether.printIp("GW:  ", ether.gwip);
  ether.printIp("DNS: ", ether.dnsip);
}

void loop() {
  int estado = digitalRead(sensor);
  Serial.print("");
  Serial.println(estado);

  word len = ether.packetReceive();
  word pos = ether.packetLoop(len);

  if (pos)  // check if valid tcp data is received
    if (estado == 0) {
      ether.httpServerReply(pageoff()); // send web page data
    }
    else {
      ether.httpServerReply(pageon()); // send web page data
    }

  if (estado == 0) {
    digitalWrite(vrm, HIGH);
    digitalWrite(vrd, LOW);
  }
  else {
    digitalWrite(vrm, LOW);
    digitalWrite(vrd, HIGH);
  }

}
static word pageon() {
  bfill = ether.tcpOffset();
  bfill.emit_p(PSTR(
                 "HTTP/1.0 200 OK\r\n"
                 "Content-Type: text/html\r\n"
                 "Pragma: no-cache\r\n"
                 "\r\n"
                 "<html>"
                 "<head><title>"
                 "LIGADO"
                 "</title></head>"
                 "<body>"
                 "<center>"
                 "<h3>LIGADO</h3>"
                 "</center>"
                 "</body>"
                 "</html>"));
  return bfill.position();
}

static word pageoff() {
  bfill = ether.tcpOffset();
  bfill.emit_p(PSTR(
                 "HTTP/1.0 200 OK\r\n"
                 "Content-Type: text/html\r\n"
                 "Pragma: no-cache\r\n"
                 "\r\n"
                 "<html>"
                 "<head><title>"
                 "DESLIGADO"
                 "</title></head>"
                 "<body>"
                 "<center>"
                 "<h3> DESLIGADO </h3>"
                 "</center>"
                 "</body>"
                 "</html>"));
  return bfill.position();
}

I saw some projects that creates pages showing results, but i couldn’t find a way to implement this.
The webpage must contain a result for each sensor, showing a text label like “sensor1up” or “sensor1down”.

Hello friends, after some research i’ve figured out how to rewrite my code. Here is the new sketch.

#include <EtherCard.h>

#define STATIC 1  //Desativa DHCP

#if STATIC
static byte myip[] = { 192, 168, 10, 98 };
static byte gwip[] = { 192, 168, 10, 101 };
#endif

static byte mymac[] = { 0x74, 0x69, 0x69, 0x2D, 0x30, 0x31 };

byte Ethernet::buffer[500]; // tcp/ip send and receive buffer

BufferFiller bfill;

int sensor1 = 2;
int sensor2 = 3;
int sensor3 = 4;
int vrd = 6;
int vrm = 7;

void setup() {
  Serial.begin(57600);
  Serial.println("\n[Iniciando...]");
  pinMode(sensor1, INPUT);
  pinMode(sensor2, INPUT);
  pinMode(sensor3, INPUT);
  pinMode(vrd, OUTPUT);
  pinMode(vrm, OUTPUT);

  if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
    Serial.println( "Failed to access Ethernet controller");
#if STATIC
  ether.staticSetup(myip, gwip);
#else
  if (!ether.dhcpSetup())
    Serial.println("DHCP failed");
#endif

  ether.printIp("IP:  ", ether.myip);
  ether.printIp("GW:  ", ether.gwip);
  ether.printIp("DNS: ", ether.dnsip);
}

void loop() {
  int estado0 = digitalRead(sensor1);
  Serial.print("");
  Serial.println(estado0);

  word len = ether.packetReceive();
  word pos = ether.packetLoop(len);

  if (pos)  // check if valid tcp data is received
    ether.httpServerReply(pageon()); // send web page data

  if (estado0 == 0) {
    digitalWrite(vrm, HIGH);
    digitalWrite(vrd, LOW);
  }
  else {
    digitalWrite(vrm, LOW);
    digitalWrite(vrd, HIGH);
  }
}

static word pageon() {
  int estado1 = digitalRead(sensor1);
  int estado2 = digitalRead(sensor2);
  int estado3 = digitalRead(sensor3);

  bfill = ether.tcpOffset();
  bfill.emit_p(PSTR(
                 "HTTP/1.0 200 OK\r\n"
                 "Content-Type: text/html\r\n"
                 "Pragma: no-cache\r\n"
                 "\r\n"
                 "<html>"
                 "<head><title>"
                 "GERADOR"
                 "</title></head>"
                 "<body>"
                 "<center>"));

  // Leitura Sensor 1/4
  if (estado1 == 0){
    bfill.emit_p(PSTR("<p style='opacity:0;'>73656e736f7231656d707479</p>")); //i've used hex tags for on and off
  }
  else{
    bfill.emit_p(PSTR("<p style='opacity:0;'>73656e736f723166756c6c</p>")); //i've used hex tags for on and off
  }
  
  bfill.emit_p(PSTR("
"));

  // Leitura Sensor 2/4
  if (estado2 == 0){
    bfill.emit_p(PSTR("<p style='opacity:0;'>73656e736f7232656d707479</p>")); //i've used hex tags for on and off
  }
  else{
    bfill.emit_p(PSTR("<p style='opacity:0;'>73656e736f723266756c6c</p>")); //i've used hex tags for on and off
  }
  
  bfill.emit_p(PSTR("
"));

  // Leitura Sensor 3/4
  if (estado3 == 0){
    bfill.emit_p(PSTR("<p style='opacity:0;'>73656e736f7233656d707479</p>"));  //i've used hex tags for on and off
  }
  else{
    bfill.emit_p(PSTR("<p style='opacity:0;'>73656e736f723366756c6c</p>")); //i've used hex tags for on and off
  }
  bfill.emit_p(PSTR(
                 "</center>"
                 "</body>"
                 "</html>"));
  return bfill.position();
}

Okay, how can we help you?