Jump to content

Getting Username from Webserver

Recommended Posts

Dear all,


I am learner in HTML coding. I am developing code on webserver application. Here what i wanna try todo.


Initially i wanna enter username and password . Once Username and password is entered . and perform add operation.

Is any software where i can create tags of my own and HTml code generated intenally and for username and password i can put test conditions

#include <SPI.h>#include <Ethernet.h>// Enter a MAC address and IP address for your controller below.// The IP address will be dependent on your local network:byte mac[] = {   0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };IPAddress ip(192,168,1,128);// Initialize the Ethernet server library// with the IP address and port you want to use // (port 80 is default for HTTP):EthernetServer server(80);void setup() { // Open serial communications and wait for port to open:  Serial.begin(9600);   while (!Serial) {    ; // wait for serial port to connect. Needed for Leonardo only  }  // start the Ethernet connection and the server:  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 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) {client.println("<!DOCTYPE html>");          client.println("<html>");           client.println("<body>");            client.println("<form action=='demo_form.asp'> Birthday: <input type='date' name='bday'> <input type='submit'>");                 client.println("<form>");        client.println("</form>");        client.println("USER name:<input type='text' name='firstname'><br>");         client.println("PASSWORD:<input type='password' name='pwd'><br>");                                                                                                   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");  }}
Link to post
Share on other sites

The problem for you will be to learn how the server provides services that are normally provided by a language such as Php. These embedded servers just run C so some sort of C library must be used to provide the server functions.




For example you need to know what C library functions can be used to set a session cookie and read the values from a submitted form.

  • Like 1
Link to post
Share on other sites

I'm not sure specifically what your question is, but your server is not checking the request at all. It receives any request, and it responds with the same form. It doesn't check the request headers to see what they are asking for, and it looks like it doesn't respond with any headers either. It also doesn't check for data in the request body (post data), or data in the URL (get data).

Link to post
Share on other sites

Dear all.




Here i am attaching Link for Understanding. I wanted To Create some tag which can talk to controller using Web server application. Intially i am new bie to web server application. From Forum i could able to create tag :


For example:

I want to Crete user name and password in Web server application.Explained here



Now user can capable of see use rname and password:


Question : Now user enter user name and password . Now how to check user name and password valid or not. ??


2) i want to create customize tag

for example: User profile contains

  1. Name:
  2. Dob
  3. profession

Edit option:

  1. Edit profile
  2. edit password
  3. edit system parameter

Each followed by Ok, SAVE, Cancel option


How to create and interlink



Link to post
Share on other sites

Now how to check user name and password valid or not. ??

Are you still doing this with the code you posted above? If so, you're going to need to expand that code first to make it a better web server. For starters, it needs to process the request and extract any data sent with the request (including the URL, which is in the headers). You might be able to find web server code that will already do that for you. Before you worry about things like checking a username and password you need a working web server.
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...