Hellrocker

store.php

Oct 3rd, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "roydl7";
  4. $password = "lolwtf";
  5. $dbname = "dht11";
  6. date_default_timezone_set("Asia/Kolkata");
  7. $logtime = date('Y-m-d H:i:s');
  8.  
  9. $temp = $_GET['temp'];
  10.  
  11. $conn = mysql_connect("localhost", $username, $password);
  12. if (!$conn)
  13. {
  14. die('Could not connect: ' . mysql_error());
  15. }
  16. $con_result = mysql_select_db("dht11", $conn);
  17. if(!$con_result)
  18. {
  19. die('Could not connect to specific database: ' . mysql_error());
  20. }
  21.  
  22. $hvalue = $temp;
  23.  
  24. $sql = "INSERT INTO `temperature` (`log`, `temp`) VALUES ('$logtime', '$temp')";
  25. $result = mysql_query($sql);
  26. if (!$result) {
  27. die('Invalid query: ' . mysql_error());
  28. }
  29. echo "<h1>THE DATA HAS BEEN SENT!!</h1>";
  30. mysql_close($conn);
  31. ?>
Add Comment
Please, Sign In to add comment