summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--create_thread.php17
1 files changed, 15 insertions, 2 deletions
diff --git a/create_thread.php b/create_thread.php
index a203b39..976bd9f 100644
--- a/create_thread.php
+++ b/create_thread.php
@@ -27,7 +27,7 @@ if (!Session::get()->is_signed_in()) {
$categories = get_all_categories();
if (count($categories) == 0) {
- echo 'There are no categories to post to!';
+ trigger_error('There are no categories to post to!');
} else {
echo '<select name="thread_cat">';
@@ -52,8 +52,21 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$thread_subject = filter_input(INPUT_POST, 'thread_subject', FILTER_SANITIZE_STRING);
$thread_cat = filter_input(INPUT_POST, 'thread_cat', FILTER_SANITIZE_NUMBER_INT);
+ $errors = array();
if (empty($thread_subject) or !$thread_subject) {
- trigger_error('Thread subject cannot be empty');
+ $errors[] = 'Thread subject cannot be empty';
+ }
+ if (empty($post_content) or !$post_content) {
+ $errors[] = 'Thread body cannot be empty';
+ }
+
+ if (!empty($errors)) {
+ $errstr = 'Please check the following problems: <ul>';
+ foreach ($errors as $err) {
+ $errstr .= '<li>' . $err . '</li>';
+ }
+ $errstr .= '</ul>';
+ trigger_error($errstr);
} else {
$thread_id = create_thread($thread_subject, $thread_cat);
create_post($post_content, $thread_id, $thread_cat);