@@ -0,0 +1,76 @@ | |||||
<!DOCTYPE html> | |||||
<html> | |||||
<head> | |||||
<meta http-equiv="refresh" content="5" > | |||||
<link rel="stylesheet" type="text/css" href="style.css" media="screen"/> | |||||
<script src="https://cdn.tailwindcss.com"></script> | |||||
<title> Sensor Data </title> | |||||
</head> | |||||
<body> | |||||
<h1>SENSOR DATA</h1> | |||||
<?php | |||||
$servername = "localhost"; | |||||
$user = "root"; | |||||
$password = ""; | |||||
$dbname = "datasensor"; | |||||
// Create connection | |||||
$conn = new mysqli($servername, $user,$password, $dbname); | |||||
// Check connection | |||||
if ($conn->connect_error) { | |||||
die("Connection failed: " . $conn->connect_error); | |||||
} | |||||
$sql = "SELECT id, Tank1, Tank2, rainwater, Turbidity,pH_sensor, reading_time FROM sensordata ORDER BY id DESC"; /*select items to display from the sensordata table in the data base*/ | |||||
echo '<table cellspacing="5" cellpadding="5"> | |||||
<tr> | |||||
<th>Storage Tank</th> | |||||
<th>PotashAlum Tank</thh> | |||||
<th>Turbidity</th> | |||||
<th>pH_sensor</th> | |||||
<th>Data Time</th> | |||||
</tr>'; | |||||
if ($result = $conn->query($sql)) { | |||||
while ($row = $result->fetch_assoc()) { | |||||
$row_Tank1 = $row["Tank1"]; | |||||
$row_Tank2 = $row["Tank2"]; | |||||
$row_Turbidity = $row["Turbidity"]; | |||||
$row_pH_sensor = $row["pH_sensor"]; | |||||
$row_reading_time = $row["reading_time"]; | |||||
echo '<tr> | |||||
<td>' . $row_Tank1 . '</td> | |||||
<td>' . $row_Tank2 . '</td> | |||||
<td>' . $row_Turbidity . '</td> | |||||
<td>' . $row_pH_sensor . '</td> | |||||
<td>' . $row_reading_time . '</td> | |||||
</tr>'; | |||||
} | |||||
$result->free(); | |||||
} | |||||
$conn->close(); | |||||
?> | |||||
</table> | |||||
</div> | |||||
</body> | |||||
</html> | |||||
</body> | |||||
</html> |
@@ -0,0 +1,52 @@ | |||||
<?php | |||||
$servername = "localhost"; | |||||
$username = "root"; | |||||
$password = ""; | |||||
$dbname = "datasensor"; | |||||
$conn = mysqli_connect($servername, $username, $password, $dbname); | |||||
$api_key_value = "ideogen"; | |||||
$api_key = $Tank1 = $Tank2 = $rainwater = $Turbidity = $pH_sensor= ""; | |||||
if ($_SERVER["REQUEST_METHOD"] == "POST") { | |||||
$api_key = test_input($_POST["api_key"]); | |||||
if($api_key == $api_key_value) { | |||||
$Tank1 = test_input($_POST["Tank1"]); | |||||
$Tank2 = test_input($_POST["Tank2"]); | |||||
$rainwater = test_input($_POST["rainwater"]); | |||||
$Turbidity = test_input($_POST["Turbidity"]); | |||||
$pH_sensor = test_input($_POST["pH_sensor"]); | |||||
$sql = "INSERT INTO sensordata ( Tank1, Tank2, rainwater, Turbidity,pH_sensor) | |||||
VALUES ('" . $Tank1 . "', '" . $Tank2 . "', '" . $rainwater . "', '" . $Turbidity . "', '" . $pH_sensor . "')"; | |||||
if ($conn->query($sql) === TRUE) { | |||||
echo "New record created successfully"; | |||||
} | |||||
else { | |||||
echo "Error: " . $sql . "<br>" . $conn->error; | |||||
} | |||||
$conn->close(); | |||||
} | |||||
else { | |||||
echo "Wrong API Key provided."; | |||||
} | |||||
} | |||||
else { | |||||
echo "No data posted with HTTP POST."; | |||||
} | |||||
function test_input($data) { | |||||
$data = trim($data); | |||||
$data = stripslashes($data); | |||||
$data = htmlspecialchars($data); | |||||
return $data; | |||||
} | |||||
?> |
@@ -0,0 +1,31 @@ | |||||
body { | |||||
background: #f5efe0; | |||||
box-sizing: border-box; | |||||
color: #000; | |||||
font-size: 1.8rem; | |||||
letter-spacing: -0.015em; | |||||
text-align: center; | |||||
} | |||||
table { | |||||
margin-left: auto; | |||||
margin-right: auto; | |||||
width: 80%; | |||||
} | |||||
th { | |||||
font-family: Arial, Helvetica, sans-serif; | |||||
font-size: 20px; | |||||
background: #666; | |||||
color: #FFF; | |||||
padding: 2px 6px; | |||||
border-collapse: separate; | |||||
border: 1px solid #000; | |||||
} | |||||
td { | |||||
font-family: Arial, Helvetica, sans-serif; | |||||
font-size: 15px; | |||||
text-align: center; | |||||
border: 1px solid #DDD; | |||||
} |
@@ -0,0 +1,26 @@ | |||||
<?php | |||||
$servername = "localhost"; | |||||
$username = "root"; | |||||
$password = ""; | |||||
$dbname = "datasensor"; | |||||
$conn = mysqli_connect($servername, $username, $password, $dbname); | |||||
$Tank1= 123; | |||||
$Tank2= 234; | |||||
$rainwater=345; | |||||
$Turbidity=678; | |||||
$pH_sensor=90; | |||||
$sql = "INSERT INTO sensordata ( Tank1, Tank2, rainwater, Turbidity,pH_sensor) | |||||
VALUES ('" . $Tank1 . "', '" . $Tank2 . "', '" . $rainwater . "', '" . $Turbidity . "', '" . $pH_sensor . "')"; | |||||
if ($conn->query($sql) === TRUE) { | |||||
echo "New record created successfully"; | |||||
} | |||||
else { | |||||
echo "Error: " . $sql . "<br>" . $conn->error; | |||||
} | |||||
$conn->close(); |