So I have written this HTML code to create a webpage and after reading an RFID tag. The page then creates a button on the webpage that must be clicked in order to upload the data to the sql database.
How do I make this automatic so when the tag is read it will automatically upload the tag data without asking the user to click the upload button?
I am trying to use the <meta http-equiv=”refresh” content=”5" />
function but am unsure where to put it in my code
An help please? how do I remove the 'upload code' button to automate the process and refresh the page each time a tag is read
void loop() {
// Check if a client has connected
client = server.available();
if (!client) {
return;
}
// Wait until the user sends some data
Serial.println("New User");
while (!client.available()) {
delay(1);
}
//Wait for serial data to be available i.e. because a tag has been scanned
if(Serial.available()) { //Read the serial port and store the data in char array
Serial.println("Data available");
for (int i=0;i<15;i++) {
val = Serial.read();
valArray[i] = val;
yield();
//delay(10)
}
Serial.print(valArray);
// write to client
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("<head>");
client.println("<title>ESP8266 Demo</title>");
client.println("</head>");
client.println("<body>");
client.println("<a href=\"/\">Refresh Status</a>");
client.println("</br></br>");
String strLink1 = "<a href='http://xxxxxxxx.com/track.php?RFID=";
String strLink2 = "'>Upload Tag ID</a>";
String strLink = strLink1 + valArray + strLink2;
client.println(strLink);
client.println("</br></br>");
client.print("RFID Tag No = ");
client.print(valArray);
client.println("</br>");
client.println("</body>");
client.println("</html>");
}
//client.stop();
delay(100);
}
You could try inserting this below the button:
<script>document.getElementsByTagName("a")[1].click();</script>
or some equivalent that is ran when needed, I'm not very clear on the when of it.