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

Размер файла: 2.24Kb
  1. <?php
  2.  
  3. define('SHCMS', true);
  4. include_once'../system/inc/basic_settings.php';
  5. if($_GET['id']){$id = $_GET['id'];}
  6. $adminka->admin();
  7. $forum = mysql_fetch_array(mysql_query("SELECT * FROM forum_cat WHERE id=$id"));
  8. $shcmsengine['title'] = 'Форум - Редактирование - '.$forum['name'].'';
  9. include_once'../template/head.php';
  10. registrat();
  11. if(!$id)
  12. {
  13. echo '<div class="errors">Вы зашли неправильно.</div>';
  14. header("Refresh:1; url=/forum/");
  15. include_once'../template/foot.php';
  16. exit;
  17. }
  18.  
  19. if($_POST['submit'])
  20. {$submit = $_POST['submit'];}
  21.  
  22. if(isset($submit))
  23. {
  24. if($_POST['name'])
  25. {$name = $_POST['name'];}
  26. if($_POST['text'])
  27. {$message = $_POST['text'];}
  28.  
  29.  
  30. if(empty($name))
  31. {
  32. echo '<div class="errors">Введите название.</div>';
  33. header("Refresh:1; url=?id=$id");
  34. include_once'../template/foot.php';
  35. exit;
  36. }
  37. if(strlen($name)<0 || strlen($name) > 50)
  38. {
  39.  
  40. echo '<div class="errors">Название не должно превышать больше 50символов.</div>';
  41. header("Refresh:1; url=?id=$id");
  42. include_once'../template/foot.php';
  43. exit;
  44. }
  45. if(strlen($message)< 0 || strlen($message)>100)
  46. {
  47. echo '<div class="errors">Описание не должно превышать больше 100символов</div>';
  48. header("Refresh:1; url=?id=$id");
  49. include_once'../template/foot.php';
  50. exit;
  51. }
  52. $ok_forum = mysql_query("UPDATE forum_cat SET name='$name', message = '$message' WHERE id= $id");
  53. if($ok_forum == true)
  54. {
  55. echo '<div class="actshcms">Параметры изменены</div>';
  56. header("Refresh:1; url=?id=$id");
  57. include_once'../template/foot.php';
  58. exit;
  59. }
  60. else
  61. {
  62. echo '<div class="errors">При редактировании возникли ошибки</div>';
  63. header("Refresh:1; url=?id=$id");
  64. include_once'../template/foot.php';
  65. exit;
  66. }
  67. }
  68. echo '<form action="?id='.$id.'&'.$conservation.'" method="post">';
  69. echo 'Название категории<br/><input type="text" name="name" value="'.$forum['name'].'"><br/>';
  70. echo 'Описание категории<br/><textarea id="text" name="text">'.$forum['message'].'</textarea><br/>';
  71. echo '<input type="submit" name="submit" value="Изменить">';
  72. echo '</form>';
  73.  
  74. include_once'../template/foot.php';
  75. ?>