I believe a have a question with a simple answer but I'm quite a novice at php and website development in general.
I'm working on a project to send some sensor data to a webpage from an arduino. Most of the website development (php and html code) was done with the assistance of an online tutorial. I have it working well with sending the data (temperature and humidity) and displaying it in a table.
However, I wish to do some testing without the use of the arduino. Specifically using a HTTP request maker like hurl.it to simulate my arduino's POST requests. I know I have all of the information available to do this but being such a novice I'm struggling to post "data" using a request maker.
My add.php file handles the POST and is as follows
<?php
include("connect.php");
$link=Connection();
$temp1=$_POST["temp1"];
$hum1=$_POST["hum1"];
$query = "INSERT INTO `tempLog` (`temperature`, `humidity`)
VALUES ('".$temp1."','".$hum1."')";
mysqli_query($link, $query);
((is_null($___mysqli_res = mysqli_close($link))) ? false : $___mysqli_res);
header("Location: index.php");
The website is also utilizing an SQL database so that's what the connect.php is referencing.
If needed the portion of the arduino code sending the data is:
h = (int) dht.readHumidity();
t = (int) dht.readTemperature();
}
data = "temp1=";
data.concat(t);
data.concat("&hum1=");
data.concat(h);
if (client.connect("www.******.com",80)) {
client.println("POST /add.php HTTP/1.1");
client.println("Host: *****.com");
client.println("Content-Type: application/x-www-form-urlencoded");
client.print("Content-Length: ");
client.println(data.length());
client.println();
client.print(data);
}
Any help on this would be greatly appreciated. I'm eventually looking to add an additional sensor to the arduino but would first like to simulate how the website would handle it with a request maker.
Thanks.
Edit: Don't believe its a duplicate problem. I'm asking how to use a request maker with my specific code. Identifying headers, etc.