MBED HTTP client with web pages for server

Dependencies:   DS1820

Fork of J_HTTP_Client by Jan Kamidra

Committer:
JohnnyK
Date:
Wed May 23 06:47:56 2018 +0000
Revision:
1:920482bc63f4
Parent:
0:d90e1f7bda1f
Repair

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JohnnyK 0:d90e1f7bda1f 1 <?php
JohnnyK 0:d90e1f7bda1f 2 $server = "sql.someweb.com"; // Here you place your MySQL server address
JohnnyK 0:d90e1f7bda1f 3 $user = "johnybravo"; // Here you place your user name of your MySQL
JohnnyK 0:d90e1f7bda1f 4 $pass = "bravo"; // Here you place your password of your MySQL
JohnnyK 0:d90e1f7bda1f 5 $db = "dtb"; // Here you place your name of your DTB
JohnnyK 0:d90e1f7bda1f 6
JohnnyK 0:d90e1f7bda1f 7 $mysql = mysql_connect($server, $user, $pass); // Connect to MySQL
JohnnyK 0:d90e1f7bda1f 8 mysql_select_db($db); // Select DTB of MySQL
JohnnyK 0:d90e1f7bda1f 9
JohnnyK 0:d90e1f7bda1f 10 if(!$mysql)
JohnnyK 0:d90e1f7bda1f 11 {
JohnnyK 0:d90e1f7bda1f 12 die("Unable connect to server!");
JohnnyK 0:d90e1f7bda1f 13 }
JohnnyK 0:d90e1f7bda1f 14
JohnnyK 0:d90e1f7bda1f 15 $doSql = mysql_query('SELECT * FROM nucleo_data WHERE id=1');
JohnnyK 0:d90e1f7bda1f 16
JohnnyK 0:d90e1f7bda1f 17 if(mysql_num_rows($doSql) == 0){
JohnnyK 0:d90e1f7bda1f 18 mysql_query('INSERT INTO nucleo_data (id, time, date, temp) VALUES (1, '.date("H:i:s",time()).', '.date("Y-m-d",time()).', 0)');
JohnnyK 0:d90e1f7bda1f 19 }
JohnnyK 0:d90e1f7bda1f 20
JohnnyK 0:d90e1f7bda1f 21 if($mysql and isset($_GET['temp'])){
JohnnyK 0:d90e1f7bda1f 22 $temp = sanitize($_GET['temp']);
JohnnyK 0:d90e1f7bda1f 23
JohnnyK 0:d90e1f7bda1f 24 $sqll = 'UPDATE nucleo_data SET temp="'.$temp.'", time="'.date("H:i:s",time()).'", date="'.date("Y-m-d",time()).'" WHERE id=1';
JohnnyK 0:d90e1f7bda1f 25 $doSqll = mysql_query($sqll);
JohnnyK 0:d90e1f7bda1f 26
JohnnyK 0:d90e1f7bda1f 27 if($doSqll){
JohnnyK 0:d90e1f7bda1f 28 echo 'Zapis byl uspesny';
JohnnyK 0:d90e1f7bda1f 29 }
JohnnyK 0:d90e1f7bda1f 30 else{
JohnnyK 0:d90e1f7bda1f 31 die('Invalid query: ' . mysql_error());
JohnnyK 0:d90e1f7bda1f 32 }
JohnnyK 0:d90e1f7bda1f 33 }
JohnnyK 0:d90e1f7bda1f 34 function sanitize($input){
JohnnyK 0:d90e1f7bda1f 35 $input = htmlspecialchars($input);
JohnnyK 0:d90e1f7bda1f 36 $input = htmlentities($input);
JohnnyK 0:d90e1f7bda1f 37 $input = strip_tags($input);
JohnnyK 0:d90e1f7bda1f 38 $input = trim($input);
JohnnyK 0:d90e1f7bda1f 39 return $input;
JohnnyK 0:d90e1f7bda1f 40 }
JohnnyK 0:d90e1f7bda1f 41 ?>