<?
define('SHCMS', true);
include_once'../system/inc/basic_settings.php';
$shcmsengine['title'] = 'Поиск по форуму';
include_once'../template/head.php';
if($_POST['submit'])
{$submit = $_POST['submit'];}
if(isset($submit))
{
if($_POST['search'])
{$search = $_POST['search'];}

if(empty($search))
{
echo '<div class="errors">Вы ничего не ввели</div>';
header("Refresh: 1; url=?");
include_once'../template/foot.php';
exit;
}
if(strlen($search)< 3 || strlen($search)>30)
{
echo '<div class="errors">Название должно быть больше 3 и меньше 30симолов</div>';
header("Refresh: 1; url=?");
include_once'../template/foot.php';
exit;
}
$search = htmlspecialchars($search);
$search = stripslashes($search);

$search_them = mysql_query("SELECT * FROM forum_them WHERE MATCH(name)  AGAINST('$search')");
if(mysql_num_rows($search_them) > 0)
{$them = mysql_fetch_array($search_them);
do
{
echo '<div class="posts"><a href="message.php?id='.$them['id'].'">'.$them['name'].'</a><br/>';
echo $them['text'];
echo '</div>';
}
while($them = mysql_fetch_array($search_them));
}
else
{
echo '<div class="errors">По вашему запросу <b>'.$search.'</b> ничего не найдено</div>';
header("Refresh: 1; url=?");
include_once'../template/foot.php';
exit();
}
}
else
{
echo '<form action="?" method="post">';
echo 'Название темы:<br/><input type="text" name="search"><br/>';
echo '<input type="submit" name="submit"><br/>';
}
include_once'../template/foot.php';

?>