SparkFun Forums 

Where electronics enthusiasts find answers.

For the discussion of Arduino related topics.
By phinsil6
#116619
Hi, I have the Arduino Dum. and the Ethernet Shield based on Wiznet 5100. I have a web page hosted on the Arduino which has forms on it. My question is, how do I read the data submitted by the form and store it as a variable in the Arduino to later use? Here is some sample code of one of the forms on the webpage:
Code: Select all
web_browser.println("<form name=\"input\" action=\"password\" method=\"get\"> Password: <input type=\"password\" name=\"PASSword\"> <input type=\"submit\" value=\"Submit\"> </form>");
Would I want to do something like a web_browser.read()?

I've been told that I can read the data and input it into a string where I can then parse and analyze. But what kind of code should I do to read the form submission?

Thanks for any help
#117249
Last year I set up an arduino web server to control a robosapien toy robot. The project page is at http://kevinhaw.com/RoboSapienServer.php and the source code is at http://kevinhaw.com/Documents/Code/RoboSapienServer.cpp.

Take a peek at the ParseHttpHeader() routine. It parses the HTTP POST coming in after a form button is pressed and if a question mark is found in it it sets the viRobsapienUrlCmd variable. This is a primitive way of doing it, as it's basically just parsing the URL for any kind of parameter and ignoring the rest of the POST request.

You'd be better off with a better parser, looking through an incoming POST request and parsing out the key/value pairs. For debugging, dump the entire POST request out your debug port and then figure out how you want to pull out the data you need. Take a peek at http://www.jmarshall.com/easy/http/#postmethod for a rundown on the syntax.

Good luck!