<?

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


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

if ( empty( $new['id'] ) ) {
    
    echo head . "<b>Ошибка</b>" . div;  
    echo link2 . 'Новость не найдена' . div;
    pod_navig();
    foot();
    exit();
    
}

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

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