<?php
/**/
define('_IN_JOHNCMS', 1);
require_once ('../incfiles/core.php');
$textl = 'Fan-klub';
require_once ('../incfiles/head.php');
if (!$user_id) {
    echo functions::display_error('Faqat sayt a\'zolari uchun!');
    require_once ('../incfiles/end.php');
    exit;
}
if ($rights < 9) {
    echo functions::display_error('Faqat Bosh admin uchun!');
    require_once ('../incfiles/end.php');
    exit;
}

if (isset($_POST['submit'])) {
    // Принимаем данные
    $name = isset($_POST['name']) ? functions::check($_POST['name']) : '';
    $sport = isset($_POST['sport']) ? functions::check($_POST['sport']) : '';
    $count = isset($_POST['count']) ? functions::check($_POST['count']) : '';
    // Проверяем на ошибки
    $error = array();
    if (!$name)
        $error[] = 'Siz klub nomini kiritmadingiz';
    if (!$sport)
        $error[] = 'Siz sport turini kiritmadingiz';
    if (!$count)
        $error[] = 'Siz mamlakat nomini kiritmadingiz';

    if (!$error) {
        /*Добавляем в базу клуб*/
        mysql_query("INSERT INTO `fanclub` SET
                `name` = '" . $name . "',
                `sport` = '" . $sport . "',
                `count` = '" . $count . "'
");
        $cid = mysql_insert_id();

        header('Location: titul_club.php?id=' . $cid . '');
    } else {
        // Выводим сообщение об ошибках
        echo functions::display_error($error);
    }
} else {


    echo '<form action="create_club.php" method="post"><div class="gmenu"><p>';

    echo '<span class="red">*</span><b>Klub nomi:</b><br /><input type="text" name="name" /><br />';
    echo '<span class="red">*</span><b>Sport turi:</b><br /><input type="text" name="sport"/><br />';
    echo '<span class="red">*</span><b>Mamlakat:</b><br /><input type="text" name="count"/><br />';

    echo '</p><p><span class="red">*</span><small>To\'ldirilishi shart!</small><br/><input type="submit" value="Klub yaratish" name="submit" />';

    echo '</p></div></form>';

    echo '<div class="phdr"><a href="index.php">Orqaga</a></div>';


}
require_once ('../incfiles/end.php');