| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- <?php
- $sql = null;
- $con = mysqli_connect("localhost", "root", "R3M0T31", "cropmonitor");
- $action=(isset($_GET["action"])) ? $_GET["action"] : "";
- $ID=(isset($_GET["ID"])) ? $_GET["ID"] : "";
- $PASSWORD=(isset($_GET["PASSWORD"])) ? $_GET["PASSWORD"] : "";
- $dateutc=(isset($_GET["dateutc"])) ? $_GET["dateutc"] : "";
- $winddir=(isset($_GET["winddir"])) ? $_GET["winddir"] : "";
- $windspeedmph=(isset($_GET["windspeedmph"])) ? $_GET["windspeedmph"] : "";
- $windgustmph=(isset($_GET["windgustmph"])) ? $_GET["windgustmph"] : "";
- $windgustdir=(isset($_GET["windgustdir"])) ? $_GET["windgustdir"] : "";
- $windspdmph_avg2m=(isset($_GET["windspdmph_avg2m"])) ? $_GET["windspdmph_avg2m"] : "";
- $winddir_avg2m=(isset($_GET["winddir_avg2m"])) ? $_GET["winddir_avg2m"] : "";
- $windgustmph_10m=(isset($_GET["windgustmph_10m"])) ? $_GET["windgustmph_10m"] : "";
- $windgustdir_10m=(isset($_GET["windgustdir_10m"])) ? $_GET["windgustdir_10m"] : "";
- $humidity=(isset($_GET["humidity"])) ? $_GET["humidity"] : "";
- $dewptf=(isset($_GET["dewptf"])) ? $_GET["dewptf"] : "";
- $tempf=(isset($_GET["tempf"])) ? $_GET["tempf"] : "";
- $temp2f=(isset($_GET["temp2f"])) ? $_GET["temp2f"] : "";
- $temp3f=(isset($_GET["temp3f"])) ? $_GET["temp3f"] : "";
- $temp4f=(isset($_GET["temp4f"])) ? $_GET["temp4f"] : "";
- $rainin=(isset($_GET["rainin"])) ? $_GET["rainin"] : "";
- $dailyrainin=(isset($_GET["dailyrainin"])) ? $_GET["dailyrainin"] : "";
- $baromin=(isset($_GET["baromin"])) ? $_GET["baromin"] : "";
- $weather=(isset($_GET["weather"])) ? $_GET["weather"] : "";
- $clouds=(isset($_GET["clouds"])) ? $_GET["clouds"] : "";
- $soiltempf=(isset($_GET["soiltempf"])) ? $_GET["soiltempf"] : "";
- $soiltemp2f=(isset($_GET["soiltemp2f"])) ? $_GET["soiltemp2f"] : "";
- $soiltemp3f=(isset($_GET["soiltemp3f"])) ? $_GET["soiltemp3f"] : "";
- $soiltemp4f=(isset($_GET["soiltemp4f"])) ? $_GET["soiltemp4f"] : "";
- $soilmoisture=(isset($_GET["soilmoisture"])) ? $_GET["soilmoisture"] : "";
- $soilmoisture2=(isset($_GET["soilmoisture2"])) ? $_GET["soilmoisture2"] : "";
- $soilmoisture3=(isset($_GET["soilmoisture3"])) ? $_GET["soilmoisture3"] : "";
- $soilmoisture4=(isset($_GET["soilmoisture4"])) ? $_GET["soilmoisture4"] : "";
- $leafwetness=(isset($_GET["leafwetness"])) ? $_GET["leafwetness"] : "";
- $leafwetness2=(isset($_GET["leafwetness2"])) ? $_GET["leafwetness2"] : "";
- $solarradiation=(isset($_GET["solarradiation"])) ? $_GET["solarradiation"] : "";
- $UV=(isset($_GET["UV"])) ? $_GET["UV"] : "";
- $visibility=(isset($_GET["visibility"])) ? $_GET["visibility"] : "";
- $indoortempf=(isset($_GET["indoortempf"])) ? $_GET["indoortempf"] : "";
- $indoorhumidity=(isset($_GET["indoorhumidity"])) ? $_GET["indoorhumidity"] : "";
- //add current datetime if not given.
- if ($dateutc === "now"){
- $dateutc = gmdate("Y-m-d\TH%3Ai%3As\Z");
- } else {
- $dateutc;
- }
- // Check connection
- if (mysqli_connect_errno())
- {
- echo "Failed to connect to MySQL: " . mysqli_connect_error();
- }
-
-
- $sql = mysqli_query($con, "INSERT INTO `weather_station`
- (
- action,
- ID,
- PASSWORD,
- dateutc,
- winddir,
- windspeedmph,
- windgustmph,
- windgustdir,
- windspdmph_avg2m,
- winddir_avg2m,
- windgustmph_10m,
- windgustdir_10m,
- humidity,
- dewptf,
- tempf,
- temp2f,
- temp3f,
- temp4f,
- rainin,
- dailyrainin,
- baromin,
- weather,
- clouds,
- soiltempf,
- soiltemp2f,
- soiltemp3f,
- soiltemp4f,
- soilmoisture,
- soilmoisture2,
- soilmoisture3,
- soilmoisture4,
- leafwetness,
- leafwetness2,
- solarradiation,
- UV,
- visibility,
- indoortempf,
- indoorhumidity
- )
- VALUES
- (
- '" . $action . "',
- '" . $ID . "',
- '" . $PASSWORD . "',
- '" . $dateutc . "',
- '" . $winddir . "',
- '" . $windspeedmph . "',
- '" . $windgustmph . "',
- '" . $windgustdir . "',
- '" . $windspdmph_avg2m . "',
- '" . $winddir_avg2m . "',
- '" . $windgustmph_10m . "',
- '" . $windgustdir_10m . "',
- '" . $humidity . "',
- '" . $dewptf . "',
- '" . $tempf . "',
- '" . $temp2f . "',
- '" . $temp3f . "',
- '" . $temp4f . "',
- '" . $rainin . "',
- '" . $dailyrainin . "',
- '" . $baromin . "',
- '" . $weather . "',
- '" . $clouds . "',
- '" . $soiltempf . "',
- '" . $soiltemp2f . "',
- '" . $soiltemp3f . "',
- '" . $soiltemp4f . "',
- '" . $soilmoisture . "',
- '" . $soilmoisture2 . "',
- '" . $soilmoisture3 . "',
- '" . $soilmoisture4 . "',
- '" . $leafwetness . "',
- '" . $leafwetness2 . "',
- '" . $solarradiation . "',
- '" . $UV . "',
- '" . $visibility . "',
- '" . $indoortempf . "',
- '" . $indoorhumidity . "'
- )
- ");
- if ($sql === TRUE)
- {
- echo "success"; //CHECKING
- } else {
- die(mysqli_error($con)); // TODO: better error handling
- //echo "User Profile incorrect";
- }
- mysqli_close($con);
|