<?php
    session_start
( );
    
    function 
forma$komunikat)
    {
    echo 
'<?xml version = "1.0" encoding = "iso-8859-2" standalone = "no" ?>' "\n";    
?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns = "http://www.w3.org/1999/xhtml" xml:lang = "pl">
    <head>
    <meta http-equiv = "Content-Type" content = "text/html; charset = iso-8859-2" />
    <meta http-equiv = "Content-Language" content = "pl" />
    <meta http-equiv = "Pragma" content = "no-cache" />
    <title>logowanie</title>
    <style type = "text/css">
    <![CDATA[
    <!--
        .wysrodkowane {
            text-align: center;
        }
    -->
    ]]>
    </style>
    </head>
        <body>
<?php
            
echo '<p class = "wysrodkowane">' $komunikat '</p><br />';
?>
            <p class = "wysrodkowane">
                <form method = post action = 65_strona.php>
                    <input type = password name = haslo><br />
                    <input type = submit name = loguj value = loguj>
                </form>
            </p>
<?php
            
exit;
?>
        </body>
    </html>
        
<?php
    
}
    
    if ( 
$_GET['akcja'] ==  'wyloguj' )  
    {
        
session_destroy( );
        
forma('Zostałeś pomyślnie wylogowany' );
    }        
    
    if ( ( !isset( 
$_SESSION['zalogowany'] ) ) && ( !isset( $_POST['haslo'] ) ) ) 
    {
        
forma('To jest prywatna część strony, wymagane jest hasło:' );
    }    
    
    if ( ( 
$_POST['haslo'] ==  'abc' ) | ( isset( $_SESSION['zalogowany'] ) ) )
    {
        
session_register ('zalogowany' );
        
$_SESSION['zalogowany'] = 'ok';
    }
    else  
    {
        
forma('Błędne hasło!!!' );
    }
?>