<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<?PHP
$filename="status.log";
if(!is_file($filename)){
$h=fopen($filename,"x");
$stfile="loggedout|Offline|Now and maybe later also";
$f=fwrite($h,$stfile);
fclose($h);
}
if(isset($_POST['log'])){
$handle=fopen($filename,"w+");
if(isset($_POST['login'])){
echo "Loggin in...";
$d="Today at " . date("g:i:s a");
$stfile="loggedin|Online|" . $d;
sleep(1);
$f=fwrite($handle,$stfile);
fclose($handle);
}
if(isset($_POST['logout'])){
$stfile="loggedout|Offline|Now and maybe later also";
$f=fwrite($handle,$stfile);
fclose($handle);
}
}
$handle=fopen($filename,"r+");
$cont=fread($handle,filesize($filename));
$st=explode("|",$cont);
$stid=$st[0];
$status=$st[1] . " as of " . $st[2];
fclose($handle);
?>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Basic insert to db</title>
<style>
#loginbox{
background-color:#e2e0d8;
border:1px solid black;
margin-left:auto;
margin-right:auto;
width:200px;
height:110px;
}
#buttons{
width:100%;
padding-left:auto;
padding-right:auto;
text-align:center;
border-bottom: 2px inset;
}
#statusbox{
width:100%;
padding-right:auto;
padding-left:auto;
text-align:center;
}
#statlabel{
font-weight:bold;
padding-left:5px;
}
#loggedin{
background-color:black;
color:#40ff40;
padding-left:2px;
border:1px solid red;
}
#loggedout{
background-color:black;
color:#ff4040;
padding-left:2px;
border:1px solid red;
}
</style>
</head>
<body>
<form action=login.php method=POST>
<div id="loginbox">
<div id="buttons">
<input type=submit name="login" value="Login">
<input type=submit name="logout" value="Logout">
<input type=hidden name="log" value="do">
</div>
<div id="statusbox"><span id="statlabel">Status:</span><div id="<?echo $stid;?>"><?echo $status;?></div></div>
</div>
</form>
</body>
</html>