 <!-- begin index.php -->
  <?php
     $dotaz=mysql_query("SELECT val FROM settings WHERE id='password';");
     $pass=mysql_fetch_row($dotaz);
     $dotaz=mysql_query("SELECT val FROM settings WHERE id='guest';");
     $guest=mysql_fetch_row($dotaz);
  ?>
  
  </div>	


            <div class="post">				
              <h2 class="title">
                <a href="#">login</a>				</h2>				
              <div class="entry">
              
              <?php echo '<form action="index.php?login=1&r='.htmlspecialchars($_GET['r']).'" method="POST">';?>             
                 <input type="hidden" name="login" value="true">
                 Heslo: <input type="password" size="20" name="ecmlogin" />
                 
                 <?php
                 if ($_POST['login']=="true") 
                   {
                     if ($_POST['ecmlogin']==$pass[0])
                       {
                        SetCookie("prihlasen", "ano");
                        SetCookie("guest", "ne");
                        if ($_GET['r']=="") {header('Location: prehled.php');} else {header('Location: '.$_GET['r']);}            
                       } 
                     else if (($_POST['ecmlogin']=="guest") && ($guest[0]=="0")) 
                       {echo '<span style="color:red;font-weight:bold;">Účet Guest je zakázán!</span>';}
                     else if (($_POST['ecmlogin']=="guest") && ($guest[0]=="1")) 
                       {
                       SetCookie("prihlasen", "ne");
                       SetCookie("guest", "ano");
                       header('Location: prehled.php');          
                        }
                     else
                       {echo '<span style="color:red;font-weight:bold;">Špatné heslo!</span>';}
                   
                   };
                 
                 if ($_POST['logout']=="true") 
                   {
                     SetCookie("prihlasen", "ne");
                     SetCookie("guest", "ne");
                     echo '<span style="font-weight:bold;">Uživatel odhlášen.</span>';
                   
                   }
                  
                 ?>
                 
                 <br/>
                 <input type="submit" value="Přihlásit se">  
              </form>                                                        
                    
              </div>			
            </div>
            
            
            
 <!-- end index.php -->