File size: 1.72Kb
<?
require_once '../core/system.php';
echo admin();
$header = 'Изменение новости';
require_once H.'core/head.php';
if (isset($_GET['id']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `news` WHERE `id` = '".intval($_GET['id'])."'"),0) == true){
$topic = mysql_fetch_array(mysql_query("SELECT * FROM `news` WHERE `id` = '".intval($_GET['id'])."'"));
} else {
$_SESSION['err'] = "Новость не найдена";
header('Location: /news/');
exit();
}
switch($act) {
case 'post':
if(isset($_POST['title']) && isset($_POST['msg'])) {
$title = check($_POST['title']);
$msg = check($_POST['msg']);
$time = time();
if(strlen($title) < 3 or strlen($name) > 30) $err = 'Длина названия должна быть в пределах 3 - 30 символов';
if(!isset($err)) {
mysql_query("UPDATE `news` SET `title` = '$title', `msg` = '$msg' WHERE `id` = '".$topic['id']."'");
header('Location: /news/');
$_SESSION['message'] = 'Новость изменена';
exit();
} else {
header('Location: ?');
$_SESSION['err'] = $err;
exit();
}
} else {
header('Location: ?');
$_SESSION['err'] = 'Введите данные';
exit();
}
break;
default;
echo '<div class="player">
<form method="post" action="?act=post&id='.$topic['id'].'">
Название
<br />
<input class="text-area" type="text" value="'.$topic['title'].'" name="title" />
Сообщение
<br />
<textarea name="msg" class = "chat-area" rows="4" cols="55"> '.$topic['msg'].'
</textarea>';
echo "<input class='inpc-ar form-submit' type='submit' value='Изменить'>
</form>
</div>
<div class='mini-line'></div>
<div class='but-list'>
<a href='/adm_root/'><img src='/images/icon/r.png'> Админ-Панель</a>
</div>";
}
require_once H.'core/foot.php';
?>