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

Размер файла: 1.96Kb
  1. <?
  2. define('SHCMS', true);
  3. include_once'../system/inc/basic_settings.php';
  4. $shcmsengine['title'] = 'Поиск по форуму';
  5. include_once'../template/head.php';
  6.  
  7. $theme = mysql_query("SELECT * FROM `forum_them`");
  8.  
  9. if(mysql_num_rows($theme) == NULL){
  10. errors("Поиск невозможен, в форуме нет ни одной темы.");
  11. include_once '../template/foot.php';
  12. exit;
  13. }
  14.  
  15. if($user_id == false) {
  16.  
  17. errors("Гости не могут использовать поиск тем");
  18. include_once '../template/foot.php';
  19. exit;
  20. }
  21.  
  22. if($_POST['submit']) {
  23. $submit = $_POST['submit'];
  24. }
  25. if(isset($submit))
  26. {
  27. if($_POST['search'])
  28. {$search = $_POST['search'];}
  29.  
  30. if(empty($search))
  31. {
  32. echo '<div class="errors">Вы ничего не ввели</div>';
  33. header("Refresh: 1; url=?");
  34. include_once'../template/foot.php';
  35. exit;
  36. }
  37. if(strlen($search)< 3 || strlen($search)>30)
  38. {
  39. echo '<div class="errors">Название должно быть больше 3 и меньше 30симолов</div>';
  40. header("Refresh: 1; url=?");
  41. include_once'../template/foot.php';
  42. exit;
  43. }
  44. $search = htmlspecialchars($search);
  45. $search = stripslashes($search);
  46.  
  47. $search_them = mysql_query("SELECT * FROM `forum_them` WHERE MATCH(name) AGAINST('$search')");
  48. if(mysql_num_rows($search_them) > 0)
  49. {$them = mysql_fetch_array($search_them);
  50. do
  51. {
  52. echo '<div class="posts"><a href="message.php?id='.$them['id'].'">'.$them['name'].'</a><br/>';
  53. echo $them['text'];
  54. echo '</div>';
  55. }
  56. while($them = mysql_fetch_array($search_them));
  57. }
  58. else
  59. {
  60. echo '<div class="errors">По вашему запросу <b>'.$search.'</b> ничего не найдено</div>';
  61. header("Refresh: 1; url=?");
  62. include_once'../template/foot.php';
  63. exit();
  64. }
  65. }
  66. else
  67. {
  68. echo '<form action="?" method="post">';
  69. echo 'Название темы:<br/><input type="text" name="search"><br/>';
  70. echo '<input type="submit" name="submit"><br/>';
  71. }
  72. include_once'../template/foot.php';
  73.  
  74. ?>