-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsensordata2.php
36 lines (27 loc) · 972 Bytes
/
sensordata2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
require 'db.php';
//----------------------------------------------------------------------------
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$temperature = escape_data($_POST["temperature"]);
$humidity = escape_data($_POST["humidity"]);
$sql = "INSERT INTO tbl_temperature1(temperature,humidity,created_date)
VALUES('" . $temperature . "','" . $humidity . "','" . date("Y-m-d H:i:s") . "')";
if ($con->query($sql) === FALSE) {
echo "Error: " . $sql . "<br>" . $con->error;
}
echo "OK. INSERT ID: ";
echo $con->insert_id;
// }
}
//----------------------------------------------------------------------------
else {
echo "No HTTP POST request found";
}
//----------------------------------------------------------------------------
function escape_data($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}