<?php
require_once '../../core/system.php';
echo only_reg();
echo moder();
if (isset($_GET['id']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `news` WHERE `id` = '$get_id'"),0) == true){
$news = mysql_fetch_assoc(mysql_query("SELECT * FROM `news` WHERE `id`  = '$get_id'"));
$news_msg = mysql_fetch_assoc(mysql_query("SELECT * FROM `news_kom` WHERE `id_news`  = '$news[id]' AND `news_content` = '1'")); 
}else{
$_SESSION['err'] = "Запись не найдена!";
header('Location: /news/');
exit();
}
$header = $news['title'];
require_once '../../core/head.php';
if(isset($_POST['title']) && isset($_POST['msg'])) {
$title = check($_POST['title']);
$msg = check($_POST['msg']);
if(strlen($title) < 3 or strlen($name) > 40) $err =  'Длина названия должна быть в пределах 3 - 40 символов';
if(strlen($msg) < 3 or strlen($msg) > 3000) $err =  'Длина сообщения должна быть в пределах 10 - 3000 символов';
if(!isset($err)) {
mysql_query("UPDATE `news` SET `title` = '$title' WHERE `id` = '$news[id]' LIMIT 1");
mysql_query("UPDATE `news_kom` SET `msg` = '$msg' WHERE `id` = '$news_msg[id]'");
header("Location: /news/post/$news[id]/");
$_SESSION['message'] = 'Запись изменена!';
exit();
}else{
header("Location: /news/post/$news[id]/");
$_SESSION['err'] = $err;
exit();
}
}
echo '<form class="player" method="post" action="?id='.$news[id].'">
Введите Название<br /><input class="text large" value="'.$news[title].'" type="text" name="title" /><br />
Введите сообщение<br /><textarea name="msg" class = "text large" rows="4" cols="55">'.$news_msg[msg].'</textarea>
<span class="btn"><span class="end"><input class="label" type="submit" value="Изменить">Изменить</span></span>
</form>
<div class="mini-line"></div><div class="player menuList">
<li><a href="/news/post/'.$news[id].'/"><img src="/images/icon/arrow.png">Назад к новости</a></li></div>';
require_once '../../core/foot.php';
?>