-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbutton2.php
57 lines (55 loc) · 1.19 KB
/
button2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<link rel="stylesheet" type="text/css" href="style.css" />
<div class="container">
<body style="background-image:url(bgimage4.jpg)">
<title>Smart Switches</title>
<h1>Internet of Things Implementation</h1>
<?php
$file = "buttonStatus2.txt";
$handle = fopen($file,'w+');
//$con = new mysqli("localhost","root","root","smartswitch");
/*if (!$con)
{
die('Could not connect: ' . mysql_error());
}
//mysql_select_db("smartswitch", $con);*/
if (isset($_POST['on']))
{
$onstring = "FAN ON";
//$sql = "INSERT INTO lightStatus (on_off) VALUES ('ON')";
fwrite($handle,$onstring);
fclose($handle);
print "
<html>
<h2>The Device has been Switched ON </h2>
</html>
";
}
else if(isset($_POST['off']))
{
$offstring = "FAN OFF";
//$sql = "INSERT INTO lightStatus (on_off) VALUES ('OFF')";
fwrite($handle, $offstring);
fclose($handle);
print "
<html>
<h2>The Device has been Switched OFF </h2>
</html>
";
}
else if(isset($_POST['auto']))
{
$autostring = "FAN AUTO";
//$sql = "INSERT INTO lightStatus (on_off) VALUES ('OFF')";
fwrite($handle, $autostring);
fclose($handle);
print "
<html>
<h2>The device functioning is now based on automatic sensor data </h2>
</html>
";
}
//$con->commit();
//$con->close();
?>
</body>
</div>