Advertisement
Guest User

php

a guest
Sep 11th, 2017
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.00 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4.     $servername = 'mysql.cba.pl';
  5.     $username = 'virtualtools';
  6.     $password = '1234Aa';
  7.     $dbname = 'virtualtools';
  8.    
  9.    
  10.     if ($_REQUEST['action']=="change"){
  11.    
  12.         $conn = new mysqli($servername, $username, $password, $dbname);
  13.    
  14.         if($conn->connection_error){
  15.             die("Connection failed: " .$conn->connection_error);
  16.         }
  17.         $sql = "UPDATE led SET led_on = NOT led_on";
  18.    
  19.         $result = $conn->query($sql);
  20.  
  21.     $conn->close();
  22.     }
  23.    
  24.     if ($_REQUEST['action']=="show"){
  25.    
  26.         $conn = new mysqli($servername, $username, $password, $dbname);
  27.    
  28.         if($conn->connection_error){
  29.             die("Connection failed: " .$conn->connection_error);
  30.         }
  31.         $sql = "SELECT led_on FROM led";
  32.    
  33.         $result = $conn->query($sql);
  34.         $row = $result->fetch_array(MYSQL_BOTH);
  35.  
  36.         echo $row[0];
  37.  
  38.     $conn->close();
  39.     }
  40. ?>
  41.  
  42.  
  43. <?php
  44. $page = $_SERVER['PHP_SELF'];
  45. $sec = "1";
  46. ?>
  47. <html>
  48.     <head>
  49.     <meta http-equiv="refresh" content="<?php echo $sec?>;URL='<?php echo $page?>'">
  50.     </head>
  51.     <body>
  52.    
  53.     </body>
  54. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement