Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

48 linhas
1.2 KiB

  1. <?php
  2. $servername = "localhost";
  3. $username = "u488983909_neonflake";
  4. $password = "Tony@1234";
  5. $dbname = "u488983909_neonflake";
  6. $conn = mysqli_connect($servername, $username, $password, $dbname);
  7. $api_key_value = "Neonflake0799";
  8. $api_key = $temperature = $luminosity = $pH= "";
  9. if ($_SERVER["REQUEST_METHOD"] == "POST") {
  10. $api_key = test_input($_POST["api_key"]);
  11. if($api_key == $api_key_value) {
  12. $Temp = test_input($_POST["temperature"]);
  13. $Lumi = test_input($_POST["luminosity"]);
  14. $ph = test_input($_POST["pH"]);
  15. $sql = "INSERT INTO espdata ( Temperature, Luminosity, pH)
  16. VALUES ('" . $Temp . "', '" . $Lumi . "', '" . $ph . "')";
  17. if ($conn->query($sql) === TRUE) {
  18. echo "New record created successfully";
  19. }
  20. else {
  21. echo "Error: " . $sql . "<br>" . $conn->error;
  22. }
  23. $conn->close();
  24. }
  25. else {
  26. echo "Wrong API Key provided.";
  27. }
  28. }
  29. else {
  30. echo "No data posted with HTTP POST.";
  31. }
  32. function test_input($data) {
  33. $data = trim($data);
  34. $data = stripslashes($data);
  35. $data = htmlspecialchars($data);
  36. return $data;
  37. }
  38. ?>