<?
/*
=============================================
Движок:  SHCMS Engine
=============================================
Название файла: Форум
=============================================
Official website: http://shcms.ru
=============================================
*/
define('SHCMS', true);
if($_GET['id']){$id = $_GET['id'];}
include_once'../system/inc/basic_settings.php';
$them2['id']= mysql_insert_id();
$tit = mysql_fetch_array(mysql_query("SELECT * FROM forum_cat WHERE id=$id"));
$shcmsengine['title'] = 'Создать новую тему в разделе '.$tit['name'].'';
include_once'../template/head.php';
registrat();

$q = mysql_query("SELECT * FROM `forum_cat` WHERE `id` = '$id'");
if (!mysql_num_rows($q)) {
      header('Refresh: 1; url=./');
   echo 'В данном разделе нельзя создавать темы';
   	include_once'../template/foot.php';
    exit();
}

if($_POST['submit'])
{$submit = $_POST['submit'];}

if(isset($submit))
{

if($_POST['name'])
{$name = $_POST['name'];}

if($_POST['message'])
{$message = $_POST['message'];}




if(isset($name) && isset($message))
{
$mysql_ok = mysql_query("INSERT INTO forum_themes (id_cat,name,message,time,user_id,author) VALUES ('$id','$name','$message','$time_date','$user_id','$login')");
$them['id']= mysql_insert_id();
mysql_query("INSERT INTO forum_messages (id_cat,id_them,message,name,time,user_id,author) VALUES ('$id','$them[id]','$message','$name','$time_date','$user_id','$login')");
if($mysql_ok == true)
{
echo'<div class="actshcms">Тема успешно создана</div>';
echo'<div class="posts"><a href="razd_new.php">Назад</a></div>';
header('Refresh: 1; url=them.php?id='.$id.'&' . $conservation . '&' );
	include_once'../template/foot.php';
exit();
}
else
{
echo'<div class="errors">Ошибка создании нового раздела</div>';
header('Refresh: 1; url=them.php?id='.$id.'&' . $conservation . '&' );
	include_once'../template/foot.php';
exit();
}}

}








echo '<form action="?id='.$id.'" method="post">';
echo 'Название темы:<br/><input type="text" name="name"><br/>';
echo 'Сообщение:<br/><textarea name="message"></textarea><br/>';
echo '<br/><input type="submit" name="submit" value="Создать тему"><br/>';
echo '<div class="posts"><a href="them.php?id='.$id.'">Назад</a></div>';
	include_once'../template/foot.php';
?>