I'm new to arduino and have never done anything in C or C++. I'm having trouble figuring out how to combine all the functions I need for a project. Here are the parts:
- I've hooked up my arduino with an ethernet shield and 6 switches.
- Right now I have successfully programmed the switches to turn on an led light when pressed
- I also want the switches, when pressed individually, to each submit information to an online form via some php the form's company gave me.
My question is:
How do I program each switch to push data to the form using the php I was given? I don't know where/how to insert it. (I've been looking at the switch and webclient examples on arduino with no luck.)
Here is the php I received: (I will be changing what exact data is sent by each switch)
$url = 'http://companywebsitehere.com/remote.php'; $data = array('did' => '1111', 'key' => 'CompanyKey', 'field_xxxx=>'1Data1', 'field_cccc'=>'2Data2', 'field_vvvv'=>'3Data3');
$options = array( 'http' => array( 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($data), ), ); $context = stream_context_create($options); $result = file_get_contents($url, false, $context);