So after a long break from writing, this series of logs will once again get an update. After reviewing the webpage code which was hard to follow, I decided to clean it up a bit and leave only what is necessary to run. As seen below the code is much more manageable and should run much smoother if you only have one light. There is still some code that can be cleaned up or removed but some will be used in my next update on the topic of adding the streaming webcam to the page. Stay tuned as more updates will follow.
<?php
if (isset($_POST["ON1"])) {
$fp = fsockopen("10.125.2.1", 23, $errno, $errstr); // Replace the IP address with your own
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
fwrite($fp, "2");
fclose($fp);
}
}
$f_pointer2 =fsockopen("10.125.2.1", 23, $errno, $errstr); // Replace the IP address with your own
fwrite($f_pointer2,'4');
$lampstat=fread($f_pointer2, 1); //1 is the character length to be read. arduino sends a char length data
fclose($f_pointer2);
if ($lampstat=='0') {
$Source3="/images/offbulb.png";
$stat2 = "Off";
} else {
$Source3="/images/onbulb.png";
$stat2 = "On";
}
$verz="2.0";
?>
<html>
<body>
<center><h1>MY LIGHTS</h1><b>Version <?php echo $verz; ?></b></center><br/>
<center><b>Lamp <?php echo $stat2?> <img src="<?php echo $Source3; ?>" alt="Light On" height="42" width="42" </a> </b></center>
<form method="post" action="temp.php" >
<center><h3>Bedroom</h3>
<input type="submit" value="Lamp" name="ON1" action="temp.php" width=20% height=10% ><br/><br/>
<!--
<br/></center>
<!--<b><img src=temp_graphShort.png></a></b><br/>
<b><img src=temp_graphtoday.png></a></b><br/>
<b><img src=temp_graph.png></a></b><br/>
<b><img src=temp_graphmonth.png></a></b><br/>
<b><img src=temp_graphyear.png></a></b><br/>
<center><b><img src="stream.php"></b><br/></center> -->
</form>
</body>
</html>
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.