Просмотр файла panel/edit_comm.php

Размер файла: 2.12Kb
<?php
define('_WBLIB',1);
require_once ('../inc/core.php');
$req = mysql_query("SELECT * FROM `comm` WHERE `id` = '$id' LIMIT 1");
$res = mysql_fetch_assoc($req);
if (mysql_num_rows($req) == 0 ) {
    require_once ('../inc/head.php');
    echo 'Комментарий не найден';
	require_once ('../inc/foot.php');
	exit; }
	
// Заголовки
$title = 'Редактирование комментария';
require_once ('../inc/head.php');
#################################
	
	echo '<div class="title">Редактирование комментария</div>';
	
	if (isset($_POST['go'])) {
        if (empty($_POST['name'])) $error = 'Вы не заполнили поле "Ваш ник"<br/>';
	    if (empty($_POST['text'])) $error.= 'Вы не заполнили поле "Отзыв"';
		if ($error) {
			echo '<div class="error">';
            echo $error;
			echo '</div>';
			 }
        else {
	
	  
	  $name = htmlspecialchars(trim($_POST['name']));
	  $text = htmlspecialchars(trim($_POST['text']));
	              $result = mysql_query("UPDATE `comm` SET
		      `text`='" . mysql_real_escape_string($text) . "',
		      `name`='" . mysql_real_escape_string($name) . "'
		      WHERE `id` = $id;");
         if ($result) header('Location: '.$home.'/comm.php?id='.$res['id_article'].'');
		 else  exit('<div class="error">Ошибка удаления комментария . Код ошибки : '.mysql_error().'</div>');
        }
    }
    echo '<div class="link"><form action="edit_comm.php?id='.$id.'" method="post" name="form">
    Ник <small>[max 100]</small><br/>
    <input name="name" type="text" maxlength="100" value="'.$res['name'].'" /><br/>
    Комментарий <small>[max 500]</small><br/>
    <textarea rows="3" name="text" maxlenght = "500">'.$res['text'].'</textarea><br/>
    <input name="go" type="submit" value="Изменить" />
    </form></div>';
	echo '<div class="bar"><a href="../comm.php?id='.$res['id_article'].'">Назад</a></div>';

echo '<div class="title"><a href="/index.php">Главная</a></div>';		
require_once ('../inc/foot.php');
?>