Location: PHPKode > projects > NewsP > login.php
<?php
session_start();
?>




<?php 
$was = $_GET["was"]; 

if(!isset($was)) 
   { 
   $was = "status"; 
   } 

if(!isset($_SESSION['username']) and $was=="status") 
   { 
   echo "Bitte erst <a href=\"?was=login\">einloggen</a>"; 
   } 

if(isset($_SESSION['username']) and $was=="status") 
   { 
   echo "Hallo ".$_SESSION['username']." <a href=\"?was=logout\">Logout</a>"; 
   } 
?>



<?php 
if($was=="login") 
{ 
echo " 
<form action=\"?was=username\" Method=\"post\"> 
Passwort:<br> 
<input type=\text\" name=\"username\" size=\"25\"><br> 
<input type=\"submit\" value=\"Absenden\"> 

</form> ";
} 
?>



<?php 
$username = $_POST["username"]; 

if($was == "username") 
   { 
   $_SESSION['username'] = $username; 
   echo "Login erfolgreich <a href=\"?was=status\">weiter</a>"; 
   } 
?>


<?php 
if($was=="logout") 
   { 
   session_destroy(); 
   echo "Logout erfolgreich <a href=\"?was=status\">weiter</a>"; 
   } 
?>
Return current item: NewsP