Combining Buttons, Webclient, & php

Hi,

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:

  1. I've hooked up my arduino with an ethernet shield and 6 switches.
  2. Right now I have successfully programmed the switches to turn on an led light when pressed
  3. 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);

How do I program each button to not only light up the led, but also push different data to the form?

You can't program the buttons. Put them back on the shirt you cut them off of, and plan to use switches, instead.

You can program the Arduino to react differently when each switch is pressed.

I just cannot figure out how to insert the php

Insert it where? That php script is going to do the same thing every time it is invoked. Hardly seems like the kind of thing that you'd want to call when 6 different events occur.