<?

include '../../config.php';
include '../../func.php';
head();


$id = num($_GET['id']);
$clan = mysql_fetch_assoc(mysql_query("SELECT * FROM `clans` WHERE `id` = '".$id."'"));

if ( empty( $clan['id'] ) ) {
    
    echo "<div class=\"head\"><b>Ошибка</b></div><div class=\"main\">";  
    echo 'Данной группы не существует.<br/>';
    pod_navig();
    foot();
    exit();
    
}

if ( isset($_POST['submit']) ) {
    
    $name = html($_POST['name']);
    $info = html($_POST['info']);
    $user = num($_POST['user']);
    $tip = num($_POST['tip']);
    
    $result = mysql_query("UPDATE `clans` SET `name` = '".$name."', `info` = '".$info."', `user` = '".$user."', `private` = '".$tip."' WHERE `id` = '".$id."'");
    if ( $result != NULL ) {
        
        header('Location: index.php?mod=clan_edit&result=good');
        
    } else {
        
        header('Location: index.php?mod=clan_edit&result=error');
        
    }    
    
    
}
echo '<form action="clan_edit.php?id='.$id.'" method="post" name="form">';
echo link2 . '
Название:<br/ ><textarea id="tarea" name="name" cols="30" rows="5" style="width: 99%;">'.$clan['name'].'</textarea><br/ ><br/ >
Описание:<br/ ><textarea id="tarea" name="info" cols="30" rows="5" style="width: 99%;">'.$clan['info'].'</textarea><br/ ><br/ >
Владелец (ID):<input type="text" name="user" value="'.$clan['user'].'" maxlength="250" size="15"/><br/ ><br/ >
Тип<br/><select name="tip">
<option value="0">Открытая</option>
<option value="1">Закрытая</option>
</select>
' . div;
echo link2 . '<input name="submit" type="submit" class="button" value="Сохранить" /></form>' . div;