View file news/comm.del.php

File size: 1.44Kb
<?php

include 'includes/config.php';
include 'includes/connect.php';
include 'includes/admin.valid.php';
include 'themes/head.php';

if (!empty($_USER['login'])) {

$id		=	intval($_GET['id']);
$empty	=	intval($_POST['empty']);
if (empty($empty)) {
	
echo 	<<<HTML
<div class="t">Удалить комментарий</div>
<div class="m">
<div class="menu2">
<form action="" method="POST">
<input type="hidden" name="empty" value="1" />
<input type="submit" class="form" value="Да" /> <a href="$home_url"><input type="button" class="form" value="Нет" /></a>
</form>
</div></div>
HTML;
	
} else {
	
	$sql		=	mysql_query("SELECT * FROM `".$db_pref."comment` WHERE `id` = '$id'");
	$nid		=	mysql_fetch_assoc($sql);
	$sql_update	=	@mysql_query("UPDATE `".$db_pref."news` SET `comm` = `comm` - 1 WHERE `id` = '$nid[news_id]'");
	$sql_delete	=	@mysql_query("DELETE FROM `".$db_pref."comment` WHERE `id` = '$id'");
	
	if ($sql_delete && $sql_update) {
		
echo 	<<<HTML
<div class="t">Удалить комментарий</div>
<div class="m">
<div class="menu2">
Комментарий успешно удален!
</div></div>
HTML;
		
	} else {
		
echo 	<<<HTML
<div class="t">Ошибка</div>
<div class="m">
<div class="menu2">
Произошла ошибка!
</div></div>
HTML;

	}
	
}

} else {
	
echo 	<<<HTML
<div class="t">Ошибка</div>
<div class="m">
<div class="menu2">
Доступ запрещен!
</div></div>
HTML;
	
}

include 'themes/foot.php';

?>