Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>
- Wyniki
- </title>
- </head>
- <body>
- //error_reporting(0); <br>
- Plik dwa.php odbiera dane wysłane metodą GET, wyświetla je i zapisuje do bazy danych <br><br>
- Czujnik : <?php echo $_GET['czujnik']?><br>
- Odczytana wartość <?php echo $_GET['wartosc']?><br>
- <?php
- $servername = "localhost";
- $database = "idxxxxxxxx_esp8266";
- $username = "idxxxxxxxx_esp8266restapi";
- $password = "xxxxxxxxxxxxxxx";
- // Create a connection
- $conn = mysqli_connect($servername, $username, $password, $database);
- // Check the connection
- if (!$conn) {
- die("Connection failed: " . mysqli_connect_error());
- }
- echo "Połączenie z bazą danych - Connected successfully";
- $name = $_GET['czujnik'];
- $date = $_GET['wartosc'];
- echo "<br> ";
- echo "$name" . " >>> ";
- echo "$date";
- echo "<br> ";
- $sql = "INSERT INTO test (nazwa, dana) VALUES ('$name', '$date')";
- if (mysqli_query($conn, $sql)) {
- echo "Komunika z zapisu danych do bazy - New record created successfully";
- } else {
- echo "Error: " . $sql . "<br>" . mysqli_error($conn);
- }
- mysqli_close($conn);
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment