<?php

include('../includes/hlava.php');
title('Klub priateľov fotografie', '../');

if ($link) {
  if ($db_selected) {
  
include('../includes/vedla.php');
odkaz('../');
include('../includes/menu.php');
menu('klub', '../');
?>        
          
        <div class="obsah">  

<?php

        if ($_SESSION['aid'] == '1') $zobraz = true;
        else $zobraz = false;
        
        if ($zobraz) {

          if (isset($_POST['submit'])) {
            if (isset($_POST['text']) AND ($_POST['text'] != '')){
      		    $sql = "UPDATE kpf_clanky C
                      SET C.text = '" . $_POST["text"] . "',
                          C.perex = '" .$_POST["perex"]. "'
                      WHERE C.cid = '" . $_GET['id'] . "';";
              $result = mysql_query($sql, $link);
          		if ($result) {
              header("Location: clanok.php?id=". $_GET['id'] ."");
              }
              else echo 'nevlozene';                      
            }              
          }
          
          $sql = "SELECT C.text, C.cid, C.nadpis, C.perex
                  FROM kpf_clanky C
                  WHERE C.cid=".$_GET['id'].";";
          
          $result = mysql_query($sql, $link);
          if ($result) {  
            $row = mysql_fetch_assoc($result);
            $perex = htmlspecialchars( $row["perex"] );
            $text = htmlspecialchars( $row["text"] );
            echo '<h2 class="cl_nadpis">'.$row['nadpis'].'</h2>';
            echo '<form class="login" action="'.$_SERVER["REQUEST_URI"] .'" method="post" enctype="multipart/form-data">';
            echo '<p><textarea name="perex" cols="100" rows="5">'.$perex.'</textarea>';
            echo '<textarea name="text" cols="100" rows="10">'.$text.'</textarea></p>';
            echo '<input class="ok" name="submit" type="submit" id="submit" value="zmeniť"/>';
            echo '</form>';
          }    
        } else echo '<p>len administrator moze menit obsah clankov.</p>';            

        		}   
	   mysql_close($link);   
 
	}
 
include('../includes/pata.php');
?>
