<?php
/* These are our valid username and passwords */
$user = 'kitava';
$pass = 'stoskus';

if (isset($_POST['username']) && isset($_POST['password'])) {
    
    if (($_POST['username'] == $user) && ($_POST['password'] == $pass)) {    
        
        if (isset($_POST['rememberme'])) {
            /* Set cookie to last 1 year */
            setcookie('username', $_POST['username'], time()+60*60*24*365);
            setcookie('password', md5($_POST['password']), time()+60*60*24*365);
        
        } else {
            /* Cookie expires when browser closes */
            setcookie('username', $_POST['username'], false);
            setcookie('password', md5($_POST['password']), false);
        }
        header('Location: news.php');
		
        
    } else {
        echo 'Neteisingai įvestas vardas arba slaptažodis';
    }
    
} else {
    echo 'Įveskite prisijungimo vardą ir slaptažodį';
}
?>