Просмотр файла forum/create_topic.php

Размер файла: 1.6Kb
<?php
require '../sys/dbconnect.php';
include_once '../sys/head.php';

$id = num($_GET['id']);
if(empty($id)){echo'<div class="name">Ошибка</div>';
include_once '../sys/foot.php';}    
$query = mysql_fetch_array(mysql_query("SELECT * FROM `forum_podcat` WHERE `id`='$id' LIMIT 1"));
if(!$query){echo'<div class="name">Такой подкатегории нет!</div>';
include_once '../sys/foot.php';} //проверка
$name = input($_POST['name']);
if(empty($name)){echo'<div class="name">Не введено название!</div>';
include_once '../sys/foot.php';}
$text = input($_POST['text']);
if(empty($text)){echo'<div class="name">Не введено сообщение!</div>';
include_once '../sys/foot.php';}
$captcha = input($_POST['captcha']);
if(empty($captcha)){echo'<div class="name">Не введена Капча!</div>';
include_once '../sys/foot.php';}
$string = file_get_contents('../caps/cap.dat');
if($captcha==$string)
{
$time = time();
mysql_query("INSERT INTO `forum_tem`  (`id_user`,`time`,`name`,`cat`,`close`) VALUES ('$user[id]','$time','$name','$id','0')");
$id_theme = mysql_insert_id();
mysql_query("INSERT INTO `forum_post` (`time`,`id_user`,`text`,`tema`) VALUES ('$time','$user[id]','$text','$id_theme')");
$f=@fopen('../caps/cap.dat', 'w+');
$text = rand('111','1111111');
@fputs($f, $text);
@fclose($f);
echo'<div class="login">Тема создана<br/>
						<a href="tema.php?id='.$id_theme.'">Перейти в тему</a></div>';
}else{
echo'<div class="login">Капча введена не верно</div>';
}
include_once '../sys/foot.php';
?>