✅ 목표 (Goal)
✅ 내용 (Contents)
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
header("Content-Type:application/json");
$host = '221.138.165.53';
$user = 'carroty';
$pw = 'Oyee8203!@#$';
$dbName = 'test';
$db_conn= new mysqli($host, $user, $pw, $dbName);
$dev_grp = $_POST['dev_grp'];
$dev_uid = $_POST['dev_uid'];
$dev_loc = $_POST['dev_loc'];
$dev_date = $_POST['dev_date'];
$dev_volt = $_POST['dev_volt'];
$dev_amp = $_POST['dev_amp'];
$temp = $_POST['temp'];
$humi = $_POST['humi'];
$pm01 = $_POST['pm01'];
$pm25 = $_POST['pm25'];
$pm10 = $_POST['pm10'];
$ext1 = $_POST['ext1'];
$ext2 = $_POST['ext2'];
$ext3 = $_POST['ext3'];
$ext_str = $_POST['ext_str'];
//echo "현재 시간 : ".date("Y-m-d H:i:s")."";
//출처: <https://extbrain.tistory.com/9> [확장형 뇌 저장소]
echo "1. dev_grp= $dev_grp"; echo "\\n";
echo "2. dev_uid= $dev_uid"; echo "\\n";
echo "3. dev_loc= $dev_loc"; echo "\\n";
echo "4. dev_date= $dev_date"; echo "\\n";
echo "5. dev_volt= $dev_volt"; echo "\\n";
echo "6. dev_amp= $dev_amp"; echo "\\n";
echo "7. temp= $temp"; echo "\\n";
echo "8. humi= $humi"; echo "\\n";
echo "9. pm01= $pm01"; echo "\\n";
echo "10. pm25= $pm25"; echo "\\n";
echo "11. pm10= $pm10"; echo "\\n";
echo "12. ext1= $ext1"; echo "\\n";
echo "13. ext2= $ext2"; echo "\\n";
echo "14. ext3= $ext3"; echo "\\n";
echo "15. ext_str= $ext_str"; echo "\\n";
// 줄바꿈 echo "<br>"이 안된다???
//https://dasima.xyz/php-echo-%EC%A4%84%EB%B0%94%EA%BF%88-4%EA%B0%80%EC%A7%80-%EB%B0%A9%EB%B2%95-%EC%A0%95%EB%A6%AC/
if($db_conn) {
//echo "MySQL successfully connected!<br/>";
//$query = "insert into data(temp, humi) values('$temp','$humi')";
//$query = "insert into `sensing_table` (`dev_id`, `time`, `temp`, `humi`, `args`) VALUES ('A001210', '2021-11-24 14:10:53', '18.5', '35', '');";
//$query = "insert into sensing_table (dev_id, time, temp, humi, args) values ('$dev_id', '$date', '$temp', '$humi', '$args');";
//$query = "insert into `sensing_table` (`dev_id`,`location`,`time`,`temp`,`humi`,`args`) values ('$dev_id','$location','$date','$temp','$humi','$args');";
$query = "insert into `sensor_data` (`dev_grp`,`dev_uid`,`dev_loc`, `dev_date`,`dev_volt`,`dev_amp`,`temp`,`humi`,`pm01`,`pm25`,`pm10`,`ext1`,`ext2`,`ext3`,`ext_str`) values ('$dev_grp','$dev_uid','$dev_loc','$dev_date','$dev_volt','$dev_amp', '$temp', '$humi', '$pm01', '$pm25', '$pm10', '$ext1', '$ext2', '$ext3', '$ext_str');";
echo $query;
//mysqli_query($db_conn,$query);
}
else {
echo "MySQL could not be connected";
}
mysqli_close($db_conn);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
<b>센서 노드 데이터</b>
<form action="process.php" method="post">
<p>1. 장치 그룹 (dev_grp): <input type="text" name="dev_grp" value="A"></p>
<p>2. 장치 고유 번호 (dev_uid): <input type="text" name="dev_uid" value="999"></p>
<p>3. 장치 위치 (dev_loc): <input type="text" name="dev_loc" value="36.335887, 126.585063"></p>
<!--"37.350339605576096, 127.10885316476644" // my offic. mi-gum station -->
<p>4. 장치 현재 시간 (dev_date): <input type="text" name="dev_date" value="2021-11-24 14:11:01"></p>
<p>5. 장치 전압 (dev_volt): <input type="text" name="dev_volt" value="5.01"></p>
<p>6. 장치 전류 (dev_amp): <input type="text" name="dev_amp" value="12.3"></p>
<p>7. 온도 (temp) : <input type="text" name="temp" value="18.5"></p>
<p>8. 습도 (humi) : <input type="text" name="humi" value="38.5"></p>
<p>9. 미세먼지 (pm01) : <input type="text" name="pm01" value="10.0"></p>
<p>10. 미세먼지 (pm25) : <input type="text" name="pm25" value="20.0"></p>
<p>11. 미세먼지 (pm10) : <input type="text" name="pm10" value="30.0"></p>
<p>12. 확장#1 (ext1) : <input type="text" name="ext1" value="1.1"></p>
<p>13. 확장#2 (ext2) : <input type="text" name="ext2" value="2.2"></p>
<p>14. 확장#3 (ext3) : <input type="text" name="ext3" value="3.3"></p>
<p>15. 추가센싱 정보 (ext_str) : <input type="text" name="ext_str" value="1234/5678/90123"></p>
<p><input type="submit" value="Send"/></p>
</form>
</body>
</html>
process.php
test.html