I've been work a project ,send character from MEGA 2560 to Wemos D1 Mini and store in webserver via phpMyadmin (localhost)
but web not showing the data i sent.
here the screenshot
my code Wemos
#include <SoftwareSerial.h>
#include <ESP8266WiFi.h>
const char* ssid = "WHYSOSERIOUS?";
const char* pass = "jokervsbatman";
const char host[] = "192.168.43.49";
char d;
SoftwareSerial EspSerial(12,SW_SERIAL_UNUSED_PIN);
long previousMillis = 0;
unsigned long currentMillis = 0;
long interval = 200; // READING INTERVAL
String data;
void setup() {
Serial.begin(115200);
EspSerial.begin(115200);
WiFi.begin(ssid,pass);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
data = "";
}
void loop(){
if(EspSerial.available()){
d=EspSerial.read();
}
Serial.print(d);
data = "data1=" + d;
WiFiClient client;
if (client.connect(host,80)) { // REPLACE WITH YOUR SERVER ADDRESS
client.println("POST /add.php HTTP/1.1");
client.println("Host: *****.*************.com"); // SERVER ADDRESS HERE TOO
client.println("Content-Type: application/x-www-form-urlencoded");
client.print("Content-Length: ");
client.println(data.length());
client.println();
client.print(data);
}
if (client.connected()) {
client.stop(); // DISCONNECT FROM THE SERVER
}
delay(300000); // WAIT FIVE MINUTES BEFORE SENDING AGAIN
}
and index.php
<?php
include("connect.php");
$link=Connection();
$result=mysql_query("SELECT * FROM `LOGGING BARCODE` LIMIT 0, 30",$link);
?>
<html>
<head>
<title>Sensor Data</title>
</head>
<body>
<h1>Temperature </h1>
<table border="1" cellspacing="1" cellpadding="1">
<tr>
<td> Timestamp </td>
<td> Data </td>
</tr>
<?php
if($result!==FALSE){
while($row = mysql_fetch_array($result)) {
printf("<tr><td> %s </td><td> %s </td><td> %s </td></tr>",
$row["Time"], $row["Data"]);
}
mysql_free_result($result);
mysql_close();
}
?>
</table>
</body>
</html>
some advice maybe helps it!
thanks