| @@ -1,29 +1,26 @@ | |||||
| <?php | <?php | ||||
| $servername = "localhost"; | $servername = "localhost"; | ||||
| $username = "root"; | |||||
| $password = ""; | |||||
| $username = "u488983909_neonflake"; | |||||
| $password = "Tony@1234"; | |||||
| $dbname = "datasensor"; | $dbname = "datasensor"; | ||||
| $conn = mysqli_connect($servername, $username, $password, $dbname); | $conn = mysqli_connect($servername, $username, $password, $dbname); | ||||
| $api_key_value = "ideogen"; | |||||
| $api_key_value = "Neonflake0799"; | |||||
| $api_key = $Tank1 = $Tank2 = $rainwater = $Turbidity = $pH_sensor= ""; | |||||
| $api_key = $temperature = $luminosity = $pH= ""; | |||||
| if ($_SERVER["REQUEST_METHOD"] == "POST") { | if ($_SERVER["REQUEST_METHOD"] == "POST") { | ||||
| $api_key = test_input($_POST["api_key"]); | $api_key = test_input($_POST["api_key"]); | ||||
| if($api_key == $api_key_value) { | 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"]); | |||||
| $Temp = test_input($_POST["temperature"]); | |||||
| $Lumi = test_input($_POST["luminosity"]); | |||||
| $ph = test_input($_POST["pH"]); | |||||
| $sql = "INSERT INTO sensordata ( Tank1, Tank2, rainwater, Turbidity,pH_sensor) | |||||
| VALUES ('" . $Tank1 . "', '" . $Tank2 . "', '" . $rainwater . "', '" . $Turbidity . "', '" . $pH_sensor . "')"; | |||||
| $sql = "INSERT INTO espdata ( Temperature, Luminosity, pH) | |||||
| VALUES ('" . $Temp . "', '" . $Lumi . "', '" . $ph . "')"; | |||||
| if ($conn->query($sql) === TRUE) { | if ($conn->query($sql) === TRUE) { | ||||
| echo "New record created successfully"; | echo "New record created successfully"; | ||||
| @@ -37,7 +34,6 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { | |||||
| else { | else { | ||||
| echo "Wrong API Key provided."; | echo "Wrong API Key provided."; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| echo "No data posted with HTTP POST."; | echo "No data posted with HTTP POST."; | ||||