I want to create an admin session to display a div on my website with stats, unviewable for everyone except for me. So i wrote this script:
AdminSessionLog in.php
Header.php:
I include header.php and footer.php and on every page, with the content between the includes.
But now the div won't show up. Can you all help me out?
AdminSessionLog in.php
Code:
<?php
include 'header.php';
$ip = $_SERVER['REMOTE_ADDR'];
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
$pass = $_POST['pass'];
$adminsetpass = "AdminPass";
if($ip = "My ip"){
if($hostname = "My ISP"){
echo '<form action="" method="post">
<input type="password" name="pass">
<input type="submit" value="sumbit"><br>
';
}
else
{
echo 'Hostname not right!';
}
}
else
{
echo 'ip Not right!!';
}
if($_SERVER['REQUEST_METHOD'] == "POST"){
if($pass == $adminsetpass){
$_SESSION['admin'] = "true";
echo 'Done';
}
else
{
echo 'Pass not right!';
}
}
include 'footer.php';
?>
Code:
<?php
session_start();
// a lot code
// Now here is the place where the div has to be:
if(isset($_SESSION['admin'])){
if($_SESSION['admin'] == "true"){
echo '<div style="display:block; bottom:0; position:fixed; text-align: center; width: 900px; background-color:red; font-size:10px;">
<?php include "online.php"; ?>
</div>
';
}
}
?>
But now the div won't show up. Can you all help me out?
Comment