<?

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


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

if ( empty( $blog['id'] ) ) {
    
    echo head . "<b>Ошибка</b>" . div;  
    echo link2 . 'Блог не найден' . div;
    pod_navig();
    foot();
    exit();
    
}

if ( isset($_POST['submit']) ) {
    
    $top = html($_POST['top']);
    $msg = html($_POST['msg']);

    $result = mysql_query("UPDATE `blogs` SET `top` = '".$top."', `msg` = '".$msg."' WHERE `id` = '".$id."'");
    if ( $result != NULL ) {
        
        
        echo rew('index.php?mod=blog_edit&result=good');
        
    } else {
        
        echo rew('index.php?mod=blog_edit&result=error');
        
    }    
    
    
}
echo '<form action="blog_edit.php?id='.$id.'" method="post" name="form">';
echo link2 . '
Топ:<br/ ><textarea id="tarea" name="top" cols="30" rows="5" style="width: 99%;">'.$blog['top'].'</textarea><br/ ><br/ >
Запись:<br/ ><textarea id="tarea" name="msg" cols="30" rows="5" style="width: 99%;">'.$blog['msg'].'</textarea><br/ ><br/ >' . div;
echo link2 . '<input name="submit" type="submit" class="button" value="Сохранить" /></form>' . div;