counter-admin.php


Quell Code


<?php
    session_start(); 


$passwort='admin';
$admin='admin';
$file='besucherzaehler.txt';
if(!file_exists($file)){
               $current = file_get_contents($file);
               $inhalt= "0";
               file_put_contents($file, $inhalt);
}else{
               $inhalt = file_get_contents($file);
}


if(!empty($_SESSION['counteradmin'])){
 if($_SESSION['counteradmin']=='admin1'){
    echo "Du bist eingeloggt als $_SESSION[counteradmin]<br>";
    $log=true;
 }
}else{
    $log=false;
}
 
if(isset($_POST['send'])){
      if($_POST['admin']==$admin && $_POST['pass']==$passwort || $log=='$true'){
          $_SESSION['counteradmin']='admin1';
          $log=true;
      }else{
           echo "Name oder Passwort falsch";
      }
}     
         
if(isset($_POST['send1'])){       
          $_SESSION['counteradmin']='admin1';
          if(!file_exists($file)){
               $current = file_get_contents($file);
               $inhalt= "0";
               file_put_contents($file, $inhalt);
          }else{
               $current = file_get_contents($file);
               $inhalt= $current + 1;
               file_put_contents($file, $inhalt);
          }
}
?>
<!DOCTYPE html>
<html lang="de">
<head>      									
	<title>Counter mit admin log</title>
	<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>itel</title>
<style>
*{
margin:0;
padding:0;
}

body {
  color: #2c3e50;
  background: #ecf0f1;
  text-align:center;
}
#counter{
  margin:40px;
  font-size:80px;
}

</style>
</head>
<body>
<?php

if($log==false){
?>
<form method="POST">
<span>Logge dich ein um den Counter zu erhöhen</span><br>
<input type="text" placeholder="Adminname..." name="admin"> ( admin )<br>
<input type="text" placeholder="Passwort..." name="pass">( admin )<br>
<input  type="submit" name="send" value="einloggen">
</form>
<?php
}else{
?>
<form method="POST">
<span> Jeder klick erhöht den Counter um ein</span><br>
<input id="hoch" type="submit" name="send1" value="Erhöhe um 1+"><br>
</form>
<?php
}
?>
<span id="counter"><?php echo $inhalt; ?></span>

</body>
</head>




Deprecated: Directive 'allow_url_include' is deprecated in Unknown on line 0