How to input arduino's data to database via wifi

we want to make a communication between arduino and php server. and there is a database to save data of sensor that we make (water level sensor). we want to input data from arduino to database and we want to display it to php server. we have a problem, we dont know how to input data sensor from arduino to database :~
Please, help us. Thank you very much :slight_smile:

Which part are you stuck on ?

Reading the data from the sensor ?
Sending it from the Arduino using wifi ?
Receiving it on the PC using wifi ?
Putting the data into the database ?

What have you tried so far ?

Please don't cross-post.

Read all chapters (part 1 to 18) of this tutorial, Arduino Ethernet Shield Web Server Tutorial
It's a very good tutorial.

Moderator edit: link to deleted cross-post message removed

@Erdin, that tutorial is good fodder, however, its for setting the arduino up as a server. What the OP wants is to talk to a web server.

@starline, to get the information to PHP is easy, I'm not sure if the arduino supports the POST method, but we can incorrectly use the GET method.

This tutorial will show how to make http requests using GET: http://arduino.cc/en/Tutorial/WebClient

Loopback.php

<?php
echo "Got Data: " . $_SERVER[ 'QUERY_STRING' ];
?>

I temporarily put this code up on my site so you can test:

arduino.genx.biz/Loopback.php?This is a test.
Returns: "Got Data: This+is+a+test."

using the function urldecode you can turn the string back into readable text.

Once you get this far you can send 'variables' which php will put in a global array for you ( $_REQUEST / $_GET / $_POST )

Loopback2.php

<?php
	print_r( $_REQUEST );
?>

http://arduino.genx.biz/Loopback2.php?VAR_A=variable_a&VAR_B=variable_b
Returns: Array ( [VAR_A] => variable_a [VAR_B] => variable_b [PHPSESSID] => a05e9f9b80d8f9bd37e4fb9b6d788d0d )

If you don't know the database stuff, read up on mysqli, however for one single sensor, maybe a flat file would be easier to use.

There are a billion examples for controlling php, a good selection are in the function reference comments on the php web site.

To UKHeliBob
we could read data from sensor, but only using the LCD. we also have already configured ip address from micrcontroller to wireless router using ethernet shield.
but we couldn't receive data using pc yet. for receiving data, we must access the ip address, mustn't we?
another problem is, we want to input data from sensor to database then we display it to web server, and we make web server with some pages and menus like home, about, etc.
but we don't understand how to code data from sensor which is sent using wifi to enter the database.
we are so sorry for our english. we are newbie :slight_smile:

To Erdin, thanks for the advice. And sorry for the crossing post. We are newbie :slight_smile:

pYro_65:
I'm not sure if the arduino supports the POST method

How hard could it be to type "POST" into the HTTP request header?

PeterH:
How hard could it be to type "POST" into the HTTP request header?

Fair enough, but maybe a more substantial solution would be appropriate.

POST data isn't sent through the URI; You would need to add the data after the request in the message body, also with appropriate MIME types.

If you were to add the data to the URL, php would parse the data into the $_GET global, leaving the $_POST variable empty... Meanwhile the page request type says it should be in $_POST.