Post and display data on webpage
hello hope u in health.
actually doing project in had post data webpage arduino .
i still not able send on web , not able display it
here arduino code
/*
web client
this sketch connects website (http://www.google.com)
using arduino wiznet ethernet shield.
circuit:
* ethernet shield attached pins 10, 11, 12, 13
created 18 dec 2009
by david a. mellis
modified 9 apr 2012
by tom igoe, based on work adrian mcewen
*/
#include <spi.h>
#include <ethernet.h>
// enter mac address controller below.
// newer ethernet shields have mac address printed on sticker on shield
byte mac[] = { 0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed };
// if don't want use dns (and reduce sketch size)
// use numeric ip instead of name server:
//ipaddress server(74,125,232,128); // numeric ip google (no dns)
char server[] = "http://wwwdata123com.000webhostapp.com"; // name address google (using dns)
// set static ip address use if dhcp fails assign
ipaddress ip(192, 168, 1, 127);
// initialize ethernet client library
// ip address , port of server
// want connect (port 80 default http):
ethernetclient client;
void setup() {
// open serial communications , wait port open:
serial.begin(9600);
while (!serial) {
; // wait serial port connect. needed native usb port only
}
// start ethernet connection:
if (ethernet.begin(mac) == 0) {
serial.println("failed configure ethernet using dhcp");
// try congifure using ip address instead of dhcp:
ethernet.begin(mac, ip);
}
// give ethernet shield second initialize:
delay(1000);
serial.println("connecting...");
string message="hello";
string data="message="+message;
// if connection, report via serial:
if (client.connect(server, 80)) {
serial.println("connected");
// make http request:
client.println("post /arduino/data.php http/1.1 200 ok");
serial.print("post /arduino/data.php http/1.1 200 ok");
//client.println("http/1.1 200 ok");
client.println("host:http://wwwdata123com.000webhostapp.com");
// client.println("user-agent: arduino/1.0");
client.println("connection: close");
client.print("content-length: ");
client.println(data.length());
client.println();
client.println(data);
serial.println("sucessfull");
} else {
// if didn't connection server:
serial.println("connection failed");
}
}
void loop() {
// if there incoming bytes available
// server, read them , print them:
if (client.available()) {
char c = client.read();
serial.print(c);
}
// if server's disconnected, stop client:
if (!client.connected()) {
serial.println();
serial.println("disconnecting.");
client.stop();
// nothing forevermore:
while (true);
}
}
in code posting hello message
here php code
<?php
$msg=$_post['message'];
echo $msg;
?>
kindly response me possible
waiting kind response
actually doing project in had post data webpage arduino .
i still not able send on web , not able display it
here arduino code
/*
web client
this sketch connects website (http://www.google.com)
using arduino wiznet ethernet shield.
circuit:
* ethernet shield attached pins 10, 11, 12, 13
created 18 dec 2009
by david a. mellis
modified 9 apr 2012
by tom igoe, based on work adrian mcewen
*/
#include <spi.h>
#include <ethernet.h>
// enter mac address controller below.
// newer ethernet shields have mac address printed on sticker on shield
byte mac[] = { 0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed };
// if don't want use dns (and reduce sketch size)
// use numeric ip instead of name server:
//ipaddress server(74,125,232,128); // numeric ip google (no dns)
char server[] = "http://wwwdata123com.000webhostapp.com"; // name address google (using dns)
// set static ip address use if dhcp fails assign
ipaddress ip(192, 168, 1, 127);
// initialize ethernet client library
// ip address , port of server
// want connect (port 80 default http):
ethernetclient client;
void setup() {
// open serial communications , wait port open:
serial.begin(9600);
while (!serial) {
; // wait serial port connect. needed native usb port only
}
// start ethernet connection:
if (ethernet.begin(mac) == 0) {
serial.println("failed configure ethernet using dhcp");
// try congifure using ip address instead of dhcp:
ethernet.begin(mac, ip);
}
// give ethernet shield second initialize:
delay(1000);
serial.println("connecting...");
string message="hello";
string data="message="+message;
// if connection, report via serial:
if (client.connect(server, 80)) {
serial.println("connected");
// make http request:
client.println("post /arduino/data.php http/1.1 200 ok");
serial.print("post /arduino/data.php http/1.1 200 ok");
//client.println("http/1.1 200 ok");
client.println("host:http://wwwdata123com.000webhostapp.com");
// client.println("user-agent: arduino/1.0");
client.println("connection: close");
client.print("content-length: ");
client.println(data.length());
client.println();
client.println(data);
serial.println("sucessfull");
} else {
// if didn't connection server:
serial.println("connection failed");
}
}
void loop() {
// if there incoming bytes available
// server, read them , print them:
if (client.available()) {
char c = client.read();
serial.print(c);
}
// if server's disconnected, stop client:
if (!client.connected()) {
serial.println();
serial.println("disconnecting.");
client.stop();
// nothing forevermore:
while (true);
}
}
in code posting hello message
here php code
<?php
$msg=$_post['message'];
echo $msg;
?>
kindly response me possible
waiting kind response
does ethernet shield have sd card? if need set chip select output , disable it
if sd chip select 4, like
have @ second part of this web client example formed http post
ps: please correct post above , add code tags around code:
[code] // code here [/code].
it should this:
(also press ctrl-t (pc) or cmd-t (mac) in ide before copying indent code properly)
if sd chip select 4, like
code: [select]
// disable sd spi
pinmode(4,output);
digitalwrite(4,high);
have @ second part of this web client example formed http post
ps: please correct post above , add code tags around code:
[code] // code here [/code].
it should this:
code: [select]
// code here
(also press ctrl-t (pc) or cmd-t (mac) in ide before copying indent code properly)
Arduino Forum > Using Arduino > Programming Questions > Post and display data on webpage
arduino
Comments
Post a Comment