[英]Validating User name and password
I am trying to implement user name and password from web Server application with Arduino board.我正在尝试使用 Arduino 板从 Web 服务器应用程序实现用户名和密码。 Here in below code i can get username and password from user.
在下面的代码中,我可以从用户那里获取用户名和密码。 Now question is how to compare result comparison.
现在的问题是如何比较结果比较。 if User enter name and password it has to check and gives back error report.
如果用户输入名称和密码,它必须检查并返回错误报告。
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,128);
EthernetServer server(80);
void setup() {
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Ethernet.begin(mac, ip);
server.begin();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
}
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 (c == '\n' && currentLineIsBlank) {
client.println("<!DOCTYPE html>");
client.println("<html>");
client.println("<body>");
client.println("</form>");
client.println("USER NAME:<input type='text' name='firstname'><br>");
client.println("PASSWORD:<input type='password' name='pwd'><br>");
client.println("<input type='submit'>");
client.println("</form>");
client.println("<body>");
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 disonnected");
}
}
查看此页面以获取受密码保护的 Arduino WebServer,我使用此提示
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.