Advertisement
Pentavus

save_data_GET.php

Sep 26th, 2019
496
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3.     // DB Configurations
  4.     $servername = "localhost";
  5.     $dbname = "e_manager";
  6.     $username = "root";
  7.     $password = "";
  8.  
  9.     $sensor1 = $_GET['sensor1'];
  10.  
  11.     $sql = "INSERT INTO `current_week`(`sensor1`) VALUES ($sensor1)";
  12.  
  13.     // Create connection
  14.     $conn = new mysqli($servername, $username, $password, $dbname);
  15.     // Check connection
  16.     if ($conn->connect_error) {
  17.         die("Connection failed: " . $conn->connect_error);
  18.     }
  19.  
  20.     // insert new record
  21.     if ($conn->query($sql) === TRUE) {
  22.         echo "New record created successfully";
  23.     }
  24.     else {
  25.         echo "Error: " . $sql . "<br>" . $conn->error;
  26.     }
  27.  
  28.     // close connection
  29.     $conn->close();
  30.  
  31. ?>
Advertisement
RAW Paste Data Copied
Advertisement