MBED HTTP client with web pages for server

Dependencies:   DS1820

Fork of J_HTTP_Client by Jan Kamidra

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers nucleoin.php Source File

nucleoin.php

00001 <?php
00002     $server = "sql.someweb.com";    // Here you place your MySQL server address
00003     $user = "johnybravo";           // Here you place your user name of your MySQL
00004     $pass = "bravo";                // Here you place your password of your MySQL
00005     $db = "dtb";                    // Here you place your name of your DTB
00006 
00007     $mysql = mysql_connect($server, $user, $pass);  // Connect to MySQL
00008     mysql_select_db($db);                           // Select DTB of MySQL
00009     
00010     if(!$mysql) 
00011     {
00012         die("Unable connect to server!");
00013     }
00014 
00015     $doSql = mysql_query('SELECT * FROM nucleo_data WHERE id=1');
00016     
00017     if(mysql_num_rows($doSql) == 0){
00018         mysql_query('INSERT INTO nucleo_data (id, time, date, temp) VALUES (1, '.date("H:i:s",time()).', '.date("Y-m-d",time()).',  0)');
00019     }
00020     
00021     if($mysql and isset($_GET['temp'])){
00022         $temp = sanitize($_GET['temp']);
00023         
00024         $sqll = 'UPDATE nucleo_data SET temp="'.$temp.'", time="'.date("H:i:s",time()).'", date="'.date("Y-m-d",time()).'" WHERE id=1';
00025         $doSqll = mysql_query($sqll);
00026 
00027         if($doSqll){ 
00028             echo 'Zapis byl uspesny';
00029         }
00030         else{
00031             die('Invalid query: ' . mysql_error());
00032         }   
00033     }
00034     function sanitize($input){
00035         $input = htmlspecialchars($input);
00036         $input = htmlentities($input);
00037         $input = strip_tags($input);
00038         $input = trim($input);
00039         return $input;
00040     }
00041 ?>