Using cURL: curl -v -d “fahren=66.66&heat=68.76&hum=34.45&dewpt=37.76&cpressure=29.900&bars=1014.5&altit=824” https://observation-weather.000webhostapp.com/BME280/dataCollector.php populates “dataDisplay.html” page.
dataCollector.php used by ESP8266 to POST data; fails to Post data to "dataDisplayer.html.
<!DOCTYPE html>
<html>
<head>
<title>>dataCollector</title>
</head>
<body>
<?php
/*
ESP8266: send data to your Domain (or mine: Embedded-iot.net/dht11/dataCollector.php)(
Uses POST command to send DHT data to a designated website
The circuit:
* BME280
* Post to Domain
Modified by to use float data type, S. Borsay's code
*/
date_default_timezone_set("America/Indianapolis");
$TimeStamp = "The current time is " . date("h:i:sa");
file_put_contents('dataDisplayer.html', $TimeStamp, FILE_APPEND);
if( $_REQUEST["fahren"] || $_REQUEST["heat"] || $_REQUEST["hum"] || $_REQUEST["dewpt"]
|| $_REQUEST["cpressure"] || $_REQUEST["bars"] || $_REQUEST["altit"] )
{
echo " The Temperature is: ". $_REQUEST['fahren']. "F. <br />";
echo " The Heat Index is: ". $_REQUEST['heat']. " Heat Index <br />";
echo " The Temperature is: ". $_REQUEST['hum']. " hum <br />";
echo " The Dew Point is: ". $_REQUEST['dewpt']. " Dew Point<br />";
echo " The Barometric Pressure is: ". $_REQUEST['cpressure']. " in. HG. <br />";
echo " The Barometric Pressure is: ". $_REQUEST['bars']. " millibars <br />";
echo " The Altitude is: ". $_REQUEST['altit']. " Feet <br />";
}
$var1 = $_REQUEST['fahren'];
$var2 = $_REQUEST['heat'];
$var3 = $_REQUEST['hum'];
$var4 = $_REQUEST['dewpt'];
$var5 = $_REQUEST['cpressure'];
$var6 = $_REQUEST['bars'];
$var7 = $_REQUEST['altit'];
$WriteMyRequest=
"<p> The Temperature is : " . $var1 . " F. </p>".
"<p>And the Heat Index is : " . $var2 . " F. </p>".
"<p>And the Humidity : " . $var3 . " % </p>".
"<p>And The Dew Point is : " . $var4 . " F. </p>".
"<p>And The Barometric Pressure is : " . $var5 . " in. HG. </p><br/>";
"<p>And The Barometric Pressure is : " . $var6 . " millibars </p><br/>";
"<p>And The Altitude is : " . $var7 . " Feet </p><br/>";
file_put_contents('dataDisplayer.html', $WriteMyRequest, FILE_APPEND);
?>
</body>
</html>
Code that sends POSI data from ESP8266 to website file: "dataCollector.php":and creates entry on "dataDisplayer.html".
if (client.connect(server, 80))
{
Serial.println("connected to server");
// if you get a connection, report back via serial:
WiFi.printDiag(Serial);
client.println("POST /BME280/dataCollector.php HTTP/1.1"); //change this if using your Sub-domain
client.print("Host: https://observation-weather.000webhostapp.com"); //change this if using your
Domain
client.println("User-Agent: ESP8266/1.0");
client.println("Connection: close");
client.println("Content-Type: application/x-www-form-urlencoded");
client.print("Content-Length: ");
client.print(data.length());
client.print(data);
client.print("\n\n");
client.flush();
client.stop();
Serial.println("\n");
Serial.println("My data string im POSTing looks like this: ");
Serial.println(data);
Serial.println("And it is this many bytes: ");
Serial.println(data.length());
Serial.println("\n");
delay(2000);
}
What permissions do I assign these two files: “dataCollector.php” and “dataDisplayer.html” ?
Is the path correct; thinking it is correct; since, it works with cURL?
William