MBED HTTP client with web pages for server

Dependencies:   DS1820

Fork of J_HTTP_Client by Jan Kamidra

Committer:
JohnnyK
Date:
Sun May 13 16:31:13 2018 +0000
Revision:
0:d90e1f7bda1f
First test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JohnnyK 0:d90e1f7bda1f 1 <?php
JohnnyK 0:d90e1f7bda1f 2 session_start();
JohnnyK 0:d90e1f7bda1f 3 if($_SESSION["uname"] != true) {header("Location: index.php");;exit();}
JohnnyK 0:d90e1f7bda1f 4
JohnnyK 0:d90e1f7bda1f 5 $server = "sql.someweb.com"; // Here you place your MySQL server address
JohnnyK 0:d90e1f7bda1f 6 $user = "johnybravo"; // Here you place your user name of your MySQL
JohnnyK 0:d90e1f7bda1f 7 $pass = "bravo"; // Here you place your password of your MySQL
JohnnyK 0:d90e1f7bda1f 8 $db = "dtb"; // Here you place your name of your DTB
JohnnyK 0:d90e1f7bda1f 9
JohnnyK 0:d90e1f7bda1f 10 $mysql = mysql_connect($server, $user, $pass); // Connect to MySQL
JohnnyK 0:d90e1f7bda1f 11 mysql_select_db($db); // Select DTB of MySQL
JohnnyK 0:d90e1f7bda1f 12
JohnnyK 0:d90e1f7bda1f 13 if(!$mysql)
JohnnyK 0:d90e1f7bda1f 14 {
JohnnyK 0:d90e1f7bda1f 15 die("Unable connect to server!")
JohnnyK 0:d90e1f7bda1f 16 }
JohnnyK 0:d90e1f7bda1f 17
JohnnyK 0:d90e1f7bda1f 18 if(isset( $_POST["submit"]))
JohnnyK 0:d90e1f7bda1f 19 {
JohnnyK 0:d90e1f7bda1f 20 If(isset($_POST["GPIO1"])){$gpio1 = 1;}else{$gpio1 = 0;}
JohnnyK 0:d90e1f7bda1f 21 If(isset($_POST["GPIO2"])){$gpio2 = 1;}else{$gpio2 = 0;}
JohnnyK 0:d90e1f7bda1f 22 If(isset($_POST["GPIO3"])){$gpio3 = 1;}else{$gpio3 = 0;}
JohnnyK 0:d90e1f7bda1f 23
JohnnyK 0:d90e1f7bda1f 24 $myfile = fopen("gpio.txt", "w") or die("Unable to open file!");
JohnnyK 0:d90e1f7bda1f 25 $txt = 'gpio:'.$gpio1.' '.$gpio2.' '.$gpio3.'';
JohnnyK 0:d90e1f7bda1f 26 fwrite($myfile, $txt);
JohnnyK 0:d90e1f7bda1f 27 fclose($myfile);
JohnnyK 0:d90e1f7bda1f 28 }
JohnnyK 0:d90e1f7bda1f 29
JohnnyK 0:d90e1f7bda1f 30 $doSql = mysql_query('SELECT * FROM nucleo_data WHERE id=1');
JohnnyK 0:d90e1f7bda1f 31 $row = mysql_fetch_array($doSql);
JohnnyK 0:d90e1f7bda1f 32 $temp = $row['temp'];
JohnnyK 0:d90e1f7bda1f 33 $time = $row['time'];
JohnnyK 0:d90e1f7bda1f 34 $date = $row['date'];
JohnnyK 0:d90e1f7bda1f 35
JohnnyK 0:d90e1f7bda1f 36 if(!file_exists("gpio.txt"))
JohnnyK 0:d90e1f7bda1f 37 {
JohnnyK 0:d90e1f7bda1f 38 $myfile = fopen("gpio.txt", "w");
JohnnyK 0:d90e1f7bda1f 39 $txt = 'gpio: 0 0 0';
JohnnyK 0:d90e1f7bda1f 40 fwrite($myfile, $txt);
JohnnyK 0:d90e1f7bda1f 41 fclose($myfile);
JohnnyK 0:d90e1f7bda1f 42 }
JohnnyK 0:d90e1f7bda1f 43 $myfile = fopen("gpio.txt", "r");
JohnnyK 0:d90e1f7bda1f 44 $gpio = fread($myfile,filesize("gpio.txt"));
JohnnyK 0:d90e1f7bda1f 45 fclose($myfile);
JohnnyK 0:d90e1f7bda1f 46 ?>
JohnnyK 0:d90e1f7bda1f 47 <!DOCTYPE html>
JohnnyK 0:d90e1f7bda1f 48 <html>
JohnnyK 0:d90e1f7bda1f 49 <head>
JohnnyK 0:d90e1f7bda1f 50 <meta charset= "utf-8">
JohnnyK 0:d90e1f7bda1f 51 <title>Input/Output</title>
JohnnyK 0:d90e1f7bda1f 52 <style>
JohnnyK 0:d90e1f7bda1f 53 body
JohnnyK 0:d90e1f7bda1f 54 {
JohnnyK 0:d90e1f7bda1f 55 margin: 0;
JohnnyK 0:d90e1f7bda1f 56 padding: 0;
JohnnyK 0:d90e1f7bda1f 57 font-family: sans-serif;
JohnnyK 0:d90e1f7bda1f 58 /*background: white url("nucleo.jpg") no-repeat fixed center;*/
JohnnyK 0:d90e1f7bda1f 59 }
JohnnyK 0:d90e1f7bda1f 60 .box
JohnnyK 0:d90e1f7bda1f 61 {
JohnnyK 0:d90e1f7bda1f 62 position: absolute;
JohnnyK 0:d90e1f7bda1f 63 top: 50%;
JohnnyK 0:d90e1f7bda1f 64 left: 50%;
JohnnyK 0:d90e1f7bda1f 65 transform: translate(-50%,-50%);
JohnnyK 0:d90e1f7bda1f 66 width: 500px;
JohnnyK 0:d90e1f7bda1f 67 padding: 40px;
JohnnyK 0:d90e1f7bda1f 68 background: rgba(0,0,0,.8);
JohnnyK 0:d90e1f7bda1f 69 box-sizing:border-box;
JohnnyK 0:d90e1f7bda1f 70 box-shadow: 0 15px 25px rgba(0,0,0,.5);
JohnnyK 0:d90e1f7bda1f 71 border-radius: 10px;
JohnnyK 0:d90e1f7bda1f 72 }
JohnnyK 0:d90e1f7bda1f 73 .box h2
JohnnyK 0:d90e1f7bda1f 74 {
JohnnyK 0:d90e1f7bda1f 75 margin: 0 50px 30px;
JohnnyK 0:d90e1f7bda1f 76 padding: 0;
JohnnyK 0:d90e1f7bda1f 77 color: #fff;
JohnnyK 0:d90e1f7bda1f 78 text-align: center;
JohnnyK 0:d90e1f7bda1f 79 }
JohnnyK 0:d90e1f7bda1f 80
JohnnyK 0:d90e1f7bda1f 81
JohnnyK 0:d90e1f7bda1f 82 .box input[type="submit"]
JohnnyK 0:d90e1f7bda1f 83 {
JohnnyK 0:d90e1f7bda1f 84 background: transparent;
JohnnyK 0:d90e1f7bda1f 85 border: none;
JohnnyK 0:d90e1f7bda1f 86 outline: none;
JohnnyK 0:d90e1f7bda1f 87 color: #fff;
JohnnyK 0:d90e1f7bda1f 88 background: #03a9f4;
JohnnyK 0:d90e1f7bda1f 89 padding: 10px 30px;
JohnnyK 0:d90e1f7bda1f 90 cursor: pointer;
JohnnyK 0:d90e1f7bda1f 91 border-radius: 5px;
JohnnyK 0:d90e1f7bda1f 92 }
JohnnyK 0:d90e1f7bda1f 93 .box input[type="submit"]:hover
JohnnyK 0:d90e1f7bda1f 94 {
JohnnyK 0:d90e1f7bda1f 95 cursor: pointer;
JohnnyK 0:d90e1f7bda1f 96 background: #92b6d5;
JohnnyK 0:d90e1f7bda1f 97 color: #fff;
JohnnyK 0:d90e1f7bda1f 98 }
JohnnyK 0:d90e1f7bda1f 99
JohnnyK 0:d90e1f7bda1f 100 .box input[type=checkbox]
JohnnyK 0:d90e1f7bda1f 101 {
JohnnyK 0:d90e1f7bda1f 102 display: none;
JohnnyK 0:d90e1f7bda1f 103 }
JohnnyK 0:d90e1f7bda1f 104
JohnnyK 0:d90e1f7bda1f 105 .box label[id="other"]
JohnnyK 0:d90e1f7bda1f 106 {
JohnnyK 0:d90e1f7bda1f 107 position: relative;
JohnnyK 0:d90e1f7bda1f 108 padding: 0 10px;
JohnnyK 0:d90e1f7bda1f 109 font-size:16px;
JohnnyK 0:d90e1f7bda1f 110 color: #fff;
JohnnyK 0:d90e1f7bda1f 111 vertical-align: middle;
JohnnyK 0:d90e1f7bda1f 112 bottom: 10px;
JohnnyK 0:d90e1f7bda1f 113 }
JohnnyK 0:d90e1f7bda1f 114
JohnnyK 0:d90e1f7bda1f 115 .box input[type="checkbox"] + label[id="check"]
JohnnyK 0:d90e1f7bda1f 116 {
JohnnyK 0:d90e1f7bda1f 117 margin: 12px 0 0 0;
JohnnyK 0:d90e1f7bda1f 118 display: inline-block;
JohnnyK 0:d90e1f7bda1f 119 width: 60px;
JohnnyK 0:d90e1f7bda1f 120 height: 30px;
JohnnyK 0:d90e1f7bda1f 121 appearance: none;
JohnnyK 0:d90e1f7bda1f 122 background: #c6c6c6;
JohnnyK 0:d90e1f7bda1f 123 outline: 0;
JohnnyK 0:d90e1f7bda1f 124 border-radius: 20px;
JohnnyK 0:d90e1f7bda1f 125 box-shadow: inset 0 0 5px;
JohnnyK 0:d90e1f7bda1f 126 transition: .5;
JohnnyK 0:d90e1f7bda1f 127 position: relative;
JohnnyK 0:d90e1f7bda1f 128 }
JohnnyK 0:d90e1f7bda1f 129 .box input:checked[type="checkbox"] + label[id="check"]
JohnnyK 0:d90e1f7bda1f 130 {
JohnnyK 0:d90e1f7bda1f 131 background: #03a9f4
JohnnyK 0:d90e1f7bda1f 132 }
JohnnyK 0:d90e1f7bda1f 133 .box input[type="checkbox"] + label[id="check"]:before
JohnnyK 0:d90e1f7bda1f 134 {
JohnnyK 0:d90e1f7bda1f 135 content: '';
JohnnyK 0:d90e1f7bda1f 136 position: absolute;
JohnnyK 0:d90e1f7bda1f 137 width: 30px;
JohnnyK 0:d90e1f7bda1f 138 height: 30px;
JohnnyK 0:d90e1f7bda1f 139 border-radius:20px;
JohnnyK 0:d90e1f7bda1f 140 top: 0;
JohnnyK 0:d90e1f7bda1f 141 left: 0;
JohnnyK 0:d90e1f7bda1f 142 background-color: white;
JohnnyK 0:d90e1f7bda1f 143 transform: scale(0.9);
JohnnyK 0:d90e1f7bda1f 144 box-shadow: 0 2px 5px rgba(0,0,0,.2);
JohnnyK 0:d90e1f7bda1f 145 transition: .5s;
JohnnyK 0:d90e1f7bda1f 146 }
JohnnyK 0:d90e1f7bda1f 147 .box input:checked[type="checkbox"]+ label[id="check"]:before
JohnnyK 0:d90e1f7bda1f 148 {
JohnnyK 0:d90e1f7bda1f 149 left: 30px;
JohnnyK 0:d90e1f7bda1f 150 }
JohnnyK 0:d90e1f7bda1f 151 .box .loader
JohnnyK 0:d90e1f7bda1f 152 {
JohnnyK 0:d90e1f7bda1f 153 position: absolute;
JohnnyK 0:d90e1f7bda1f 154 top: 57%;
JohnnyK 0:d90e1f7bda1f 155 left: 68%;
JohnnyK 0:d90e1f7bda1f 156 transform: translate(-50%, -50%);
JohnnyK 0:d90e1f7bda1f 157 width: 200px;
JohnnyK 0:d90e1f7bda1f 158 height: 200px;
JohnnyK 0:d90e1f7bda1f 159 box-sizing: border-box;
JohnnyK 0:d90e1f7bda1f 160 }
JohnnyK 0:d90e1f7bda1f 161 .box .loader .face
JohnnyK 0:d90e1f7bda1f 162 {
JohnnyK 0:d90e1f7bda1f 163 position: absolute;
JohnnyK 0:d90e1f7bda1f 164 border: 2px solid #121212;
JohnnyK 0:d90e1f7bda1f 165 }
JohnnyK 0:d90e1f7bda1f 166 .box .loader .face.face1
JohnnyK 0:d90e1f7bda1f 167 {
JohnnyK 0:d90e1f7bda1f 168 top: 0;
JohnnyK 0:d90e1f7bda1f 169 left: 0;
JohnnyK 0:d90e1f7bda1f 170 right: 0;
JohnnyK 0:d90e1f7bda1f 171 bottom: 0;
JohnnyK 0:d90e1f7bda1f 172 background: transparent;
JohnnyK 0:d90e1f7bda1f 173 box-shadow: 0 0 10px rgba(0,0,0,1);
JohnnyK 0:d90e1f7bda1f 174 border-radius:50%;
JohnnyK 0:d90e1f7bda1f 175 border-left: 2px solid #ffff00;
JohnnyK 0:d90e1f7bda1f 176 border-top: 2px solid #ffff00;
JohnnyK 0:d90e1f7bda1f 177 animation: animate 10s linear infinite;
JohnnyK 0:d90e1f7bda1f 178 }
JohnnyK 0:d90e1f7bda1f 179 .box .loader .face.face2
JohnnyK 0:d90e1f7bda1f 180 {
JohnnyK 0:d90e1f7bda1f 181 top: 20px;
JohnnyK 0:d90e1f7bda1f 182 left: 20px;
JohnnyK 0:d90e1f7bda1f 183 right: 20px;
JohnnyK 0:d90e1f7bda1f 184 bottom: 20px;
JohnnyK 0:d90e1f7bda1f 185 background: transparent;
JohnnyK 0:d90e1f7bda1f 186 box-shadow: 0 0 10px rgba(0,0,0,1);
JohnnyK 0:d90e1f7bda1f 187 border-radius:50%;
JohnnyK 0:d90e1f7bda1f 188 border-right: 2px solid #03a9f4;
JohnnyK 0:d90e1f7bda1f 189 border-bottom: 2px solid #03a9f4;
JohnnyK 0:d90e1f7bda1f 190 animation: animate 30s linear reverse infinite;
JohnnyK 0:d90e1f7bda1f 191 }
JohnnyK 0:d90e1f7bda1f 192 .box .loader .face .circle
JohnnyK 0:d90e1f7bda1f 193 {
JohnnyK 0:d90e1f7bda1f 194 position: absolute;
JohnnyK 0:d90e1f7bda1f 195 top: calc(50% - 1px);
JohnnyK 0:d90e1f7bda1f 196 left: 50%;
JohnnyK 0:d90e1f7bda1f 197 width: 50%;
JohnnyK 0:d90e1f7bda1f 198 height: 2px;
JohnnyK 0:d90e1f7bda1f 199 transform-origin: left;
JohnnyK 0:d90e1f7bda1f 200 }
JohnnyK 0:d90e1f7bda1f 201 .box .loader .face.face1 .circle
JohnnyK 0:d90e1f7bda1f 202 {
JohnnyK 0:d90e1f7bda1f 203 transform: rotate(-45deg);
JohnnyK 0:d90e1f7bda1f 204 }
JohnnyK 0:d90e1f7bda1f 205 .box .loader .face.face2 .circle
JohnnyK 0:d90e1f7bda1f 206 {
JohnnyK 0:d90e1f7bda1f 207 transform: rotate(-45deg);
JohnnyK 0:d90e1f7bda1f 208 }
JohnnyK 0:d90e1f7bda1f 209 .box .loader .face .circle:before
JohnnyK 0:d90e1f7bda1f 210 {
JohnnyK 0:d90e1f7bda1f 211 content: '';
JohnnyK 0:d90e1f7bda1f 212 position: absolute;
JohnnyK 0:d90e1f7bda1f 213 width: 10px;
JohnnyK 0:d90e1f7bda1f 214 height: 10px;
JohnnyK 0:d90e1f7bda1f 215 border-radius: 50%;
JohnnyK 0:d90e1f7bda1f 216 background: #fff;
JohnnyK 0:d90e1f7bda1f 217 top: -4px;
JohnnyK 0:d90e1f7bda1f 218 right: -6px;
JohnnyK 0:d90e1f7bda1f 219 }
JohnnyK 0:d90e1f7bda1f 220 .box .loader .face.face1 .circle:before
JohnnyK 0:d90e1f7bda1f 221 {
JohnnyK 0:d90e1f7bda1f 222 background: #ffff00;
JohnnyK 0:d90e1f7bda1f 223 box-shadow: 0 0 20px #ff0,
JohnnyK 0:d90e1f7bda1f 224 0 0 40px #ff0,
JohnnyK 0:d90e1f7bda1f 225 0 0 60px #ff0,
JohnnyK 0:d90e1f7bda1f 226 0 0 80px #ff0,
JohnnyK 0:d90e1f7bda1f 227 0 0 100px #ff0,
JohnnyK 0:d90e1f7bda1f 228 0 0 0 5px rgba(255,255,0,.1);
JohnnyK 0:d90e1f7bda1f 229 }
JohnnyK 0:d90e1f7bda1f 230 .box .loader .face.face2 .circle:before
JohnnyK 0:d90e1f7bda1f 231 {
JohnnyK 0:d90e1f7bda1f 232 background: #03a9f4;
JohnnyK 0:d90e1f7bda1f 233 box-shadow: 0 0 20px #03a9f4,
JohnnyK 0:d90e1f7bda1f 234 0 0 40px #03a9f4,
JohnnyK 0:d90e1f7bda1f 235 0 0 60px #03a9f4,
JohnnyK 0:d90e1f7bda1f 236 0 0 80px #03a9f4,
JohnnyK 0:d90e1f7bda1f 237 0 0 100px #03a9f4,
JohnnyK 0:d90e1f7bda1f 238 0 0 0 5px rgba(3,169,244,.1);
JohnnyK 0:d90e1f7bda1f 239 }
JohnnyK 0:d90e1f7bda1f 240 @keyframes animateCircle
JohnnyK 0:d90e1f7bda1f 241 {
JohnnyK 0:d90e1f7bda1f 242 0%
JohnnyK 0:d90e1f7bda1f 243 {
JohnnyK 0:d90e1f7bda1f 244 transform: rotate(0deg);
JohnnyK 0:d90e1f7bda1f 245 }
JohnnyK 0:d90e1f7bda1f 246 100%
JohnnyK 0:d90e1f7bda1f 247 {
JohnnyK 0:d90e1f7bda1f 248 transform: rotate(360deg);
JohnnyK 0:d90e1f7bda1f 249 }
JohnnyK 0:d90e1f7bda1f 250 }
JohnnyK 0:d90e1f7bda1f 251 @keyframes animate
JohnnyK 0:d90e1f7bda1f 252 {
JohnnyK 0:d90e1f7bda1f 253 0%
JohnnyK 0:d90e1f7bda1f 254 {
JohnnyK 0:d90e1f7bda1f 255 transform: rotate(45deg);
JohnnyK 0:d90e1f7bda1f 256 }
JohnnyK 0:d90e1f7bda1f 257 100%
JohnnyK 0:d90e1f7bda1f 258 {
JohnnyK 0:d90e1f7bda1f 259 transform: rotate(405deg);
JohnnyK 0:d90e1f7bda1f 260 }
JohnnyK 0:d90e1f7bda1f 261 }
JohnnyK 0:d90e1f7bda1f 262 .loader .text
JohnnyK 0:d90e1f7bda1f 263 {
JohnnyK 0:d90e1f7bda1f 264 color: #fff;
JohnnyK 0:d90e1f7bda1f 265 top: 35%;
JohnnyK 0:d90e1f7bda1f 266 position: relative;
JohnnyK 0:d90e1f7bda1f 267 text-align: center;
JohnnyK 0:d90e1f7bda1f 268 font-size: 16px;
JohnnyK 0:d90e1f7bda1f 269 }
JohnnyK 0:d90e1f7bda1f 270 </style>
JohnnyK 0:d90e1f7bda1f 271 </head>
JohnnyK 0:d90e1f7bda1f 272 <body>
JohnnyK 0:d90e1f7bda1f 273 <div class="box">
JohnnyK 0:d90e1f7bda1f 274 <h2>Control panel</h2>
JohnnyK 0:d90e1f7bda1f 275 <form method="POST" action="#">
JohnnyK 0:d90e1f7bda1f 276 <div>
JohnnyK 0:d90e1f7bda1f 277 <input type="checkbox" name="GPIO1" id="checkbox_1" value="" <?php echo ($gpio[5]==1 ? 'checked' : '');?>><label id="check" for ="checkbox_1"></label>
JohnnyK 0:d90e1f7bda1f 278 <label id="other" for ="checkbox_1">LED1</label>
JohnnyK 0:d90e1f7bda1f 279 </br>
JohnnyK 0:d90e1f7bda1f 280 <input type="checkbox" name="GPIO2" id="checkbox_2" value="1" <?php echo ($gpio[7]==1 ? 'checked' : '');?>><label id="check" for ="checkbox_2"></label>
JohnnyK 0:d90e1f7bda1f 281 <label id="other" for ="checkbox_1">LED2</label>
JohnnyK 0:d90e1f7bda1f 282 </br>
JohnnyK 0:d90e1f7bda1f 283 <input type="checkbox" name="GPIO3" id="checkbox_3" value="1" <?php echo ($gpio[9]==1 ? 'checked' : '');?>><label id="check" for ="checkbox_3"></label>
JohnnyK 0:d90e1f7bda1f 284 <label id="other" for ="checkbox_1">LED3</label>
JohnnyK 0:d90e1f7bda1f 285 </div>
JohnnyK 0:d90e1f7bda1f 286 </br>
JohnnyK 0:d90e1f7bda1f 287 <div class="loader">
JohnnyK 0:d90e1f7bda1f 288 <div class="text">Temperature: <?php if(isset($temp)) { echo $temp; } ?>&#8451;</br> Date: <?php if(isset($date)) { echo $date; } ?></br>Time: <?php if(isset($time)) { echo $time; } ?></div>
JohnnyK 0:d90e1f7bda1f 289 <div class="face face1">
JohnnyK 0:d90e1f7bda1f 290 <div class="circle"></div>
JohnnyK 0:d90e1f7bda1f 291 </div>
JohnnyK 0:d90e1f7bda1f 292 <div class="face face2">
JohnnyK 0:d90e1f7bda1f 293 <div class="circle"></div>
JohnnyK 0:d90e1f7bda1f 294 </div>
JohnnyK 0:d90e1f7bda1f 295 </div>
JohnnyK 0:d90e1f7bda1f 296 <input type="submit" name="submit" value="submit">
JohnnyK 0:d90e1f7bda1f 297 </form>
JohnnyK 0:d90e1f7bda1f 298 </div>
JohnnyK 0:d90e1f7bda1f 299 </body>
JohnnyK 0:d90e1f7bda1f 300 </html>