<?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('sutaze', '../');
?>       
               
            <ul class="menu pmenu">
              <li><a href="index.php" title="Súťaže">Súťaže</a></li>
          
<?php
if (!(isset($_SESSION['login']) && ($_SESSION['login'] != ""))) :
// pouzivatel sa musi prihlasit, treba zobrazit prihlasovaci formular
?>
<?
else :
// pouzivatel je prihlaseny
    ?>
              <li class="medzera">&nbsp;</li>
              <li><a href="vloz.php" class="aktual" title="vloženie súťaže">Vložiť súťaž</a></li>
    
<?php
endif; // kontrola SESSION
        	
?>                    
          
            </ul> 
          
        <div class="obsah">  
      
<h2>Vložiť <em>súťaž</em></h2>


	
<?php

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

  if (isset($_POST["submit"])){
  
  if (isset($_POST['nadpis']) && ($_POST['nadpis'] != "") &&
      isset($_POST['kategoria']) && ($_POST['kategoria'] != "NULL") &&
      isset($_POST['organizator']) && ($_POST['organizator'] != "") &&
      isset($_POST['web']) && ($_POST['web'] != "") &&
      isset($_POST['temy']) && ($_POST['temy'] != "") &&
      isset($_POST['pravidla']) && ($_POST['pravidla'] != "") &&
      isset($_POST['poplatok']) && ($_POST['poplatok'] != "")  ){
      
        $sql = "INSERT INTO kpf_sutaze (sid, aid, nadpis, kategoria, organizator, kontakt, termin, tema, popis, poplatok, cas) VALUES (NULL, '".$_SESSION['aid']."', '".$_POST['nadpis']."', '".$_POST['kategoria']."', '".$_POST['organizator']."', '".$_POST['web']."', '".$_POST['den'].". ".$_POST['mesiac'].". ".$_POST['rok']."', '".$_POST['temy']."', '".$_POST['pravidla']."', '".$_POST['poplatok']."', NOW());";
        $result = mysql_query($sql, $link);	
            if ($result) {
              header("Location: index.php");
            } else echo 'nevlozil';    
      } else echo '<p>Je potrebné aby boli vyplnené všetky položky!</p>';
    
    
           
            /*$sql = "INSERT INTO kpf_clanky (cid, aid, nadpis, perex, text, kategoria, cas) VALUES (NULL, '".$_SESSION['aid']."', '" . $_POST["nadpis"] . "', '" . nl2br($_POST["perex"]) . "', '" . $_POST["editor"] . "', '" . $_POST["kategoria"] . "', NOW());";
            $result = mysql_query($sql, $link);	
            if ($result) {
              $sql2 = "SELECT C.cid
                       FROM kpf_clanky C
                       ORDER BY cas DESC
                       LIMIT 1;";
              $result2 = mysql_query($sql2, $link);
              if ($result2) {
              $row = mysql_fetch_assoc($result2);
              
              if ($_POST['kategoria'] != 'Fototéma'){
                $sql2 = "SELECT A.mail
                        FROM kpf_author A
                        WHERE rss_clanok='1';";
                $result2 = mysql_query($sql2, $link);
                if ($result2) {
                    $i = '0';
                    while ($row2 = mysql_fetch_assoc($result2)) {
                      if ($i != '0')
                        $maily .=", ";
                      $maily .= $row2['mail'];
                      $i++;
                    }
                    mail("$maily", "Novy clanok na sedf-klub.sk", 
                         "Mily priatel fotografie:)\n\nNa klubovej stranke je novy clanok:\nhttp://sedf-klub.sk/klub/clanok.php?id=".$row['cid']."\n\nAk nechces dostavať informacie o novych clankoch klikni na http://sedf-klub.sk/nastav.php.\n\nS pozdravom\nJano Duriga", "from: kpf@sedf-klub.sk");
                }
              }              
              
              header("Location: clanok.php?id=". $row['cid'] ."");
              }
            }*/
    //} //else {echo '<p>Je potrebné aby boli vyplnené všetky položky!</p>'; } 
  }
  
?>	
	
	  <!--action="sampleposteddata.php" -->
		<form class="login" action="<?php echo $_SERVER['REQUEST_URI'] ?>" method="post">
		<p class="form"><em class="bold">Názov súťaže</em><input name="nadpis" size="55" type="text" maxlength="35" /><br />
      <em class="bold">Kategória</em> <select name="kategoria">
                                          <option value="NULL" selected="selected">Vyber kategoriu!</option>
                                          <option value="Jednotlivci">Jednotlivci</option>
                                          <option value="Kluby">Kluby</option>
                                          <option value="Naše">Naše</option>
                                        </select><br />
  		<em class="bold">Organizátor</em><input name="organizator" size="55" type="text" maxlength="35" /><br />
  		<em class="bold">Web súťaže</em><input name="web" size="55" type="text" maxlength="35" /><br />
  		<em class="bold">Uzávierka</em><select name="den">
                                    <option value="01" selected="selected">01</option><option value="02">02</option><option value="03">03</option><option value="04">04</option><option value="05">05</option><option value="06">06</option><option value="07">07</option><option value="08">08</option><option value="09">09</option>
                                    <option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option>                                    
                                    <option value="20">20</option><option value="21">21</option><option value="22">22</option><option value="23">23</option><option value="24">24</option><option value="25">25</option><option value="26">26</option><option value="27">27</option><option value="28">28</option><option value="29">29</option>
                                    <option value="30">30</option><option value="31">31</option>
                                  </select>
                                  <select name="mesiac">
                                    <option value="01" selected="selected">Január</option>
                                    <option value="02">Február</option>
                                    <option value="03">Marec</option>
                                    <option value="04">Apríl</option>
                                    <option value="05">Máj</option>
                                    <option value="06">Jún</option>
                                    <option value="07">Júl</option>
                                    <option value="08">August</option>
                                    <option value="09">September</option>
                                    <option value="10">Október</option>
                                    <option value="11">November</option>
                                    <option value="12">December</option>
                                  </select>
                                  <select name="rok">
                                    <option value="2009" selected="selected">2009</option>
                                    <option value="2010">2010</option>
                                    <option value="2011">2011</option>
                                  </select><br />
  		<em class="bold">Témy</em><textarea name="temy" cols="31" rows="2"><?php echo $_POST['perex']?></textarea><br />
  		<em class="bold">Pravidlá</em><textarea name="pravidla" cols="31" rows="4"><?php echo $_POST['perex']?></textarea><br />
      <em class="bold">Poplatok</em><input name="poplatok" size="55" type="text" maxlength="35" /></p>
    <p class="form">
      <em class="bold"></em></p>
			<input class="ok" name="submit" type="submit" value="Vložiť" />
		</form>
 
<?php
  }
  else echo '<p>vkladať članky môže len prihlásený používateľ.</p>';
        		}   
	   mysql_close($link);   
 
	}
include('../includes/pata.php'); 
?>