diff options
author | h5p9sl <21267024+h5p9sl@users.noreply.github.com> | 2021-05-13 22:07:11 -0600 |
---|---|---|
committer | h5p9sl <21267024+h5p9sl@users.noreply.github.com> | 2021-05-14 02:37:13 -0600 |
commit | fe41f57df59c7f2a11d80eaaebf08d3a3a51a6d5 (patch) | |
tree | 8917741bbe991d6ddf4f23953309288975f56eb2 /viewthread.php | |
parent | 4145fa13230d25d9978c003a8cccd1b7c2e11aaf (diff) |
Add error handling
Diffstat (limited to 'viewthread.php')
-rw-r--r-- | viewthread.php | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/viewthread.php b/viewthread.php index e8eda06..fa1c81b 100644 --- a/viewthread.php +++ b/viewthread.php @@ -68,29 +68,30 @@ foreach ($posts as $post) { ?> <hr> <h2>Reply to this thread</h2> -<form method="post"> - <textarea name="post_content" rows="10" cols="50"></textarea> - <br> - <input type="submit" name="submit"> -</form> -</body> -</html> <?php include_once 'includes/functions_post.php'; +include_once 'includes/error.php'; if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (!Session::get()->is_signed_in()) { - echo 'You must be <a href="signin.php">signed in</a> to reply to this thread.'; + trigger_error('You must be <a href="signin.php">signed in</a> to reply to this thread.', E_USER_NOTICE); return; } $post_content = filter_input(INPUT_POST, 'post_content', FILTER_SANITIZE_STRING); if (empty($post_content) or !$post_content) { - echo 'Thread subject cannot be empty'; + trigger_error('Reply cannot be empty'); } else { create_post($post_content, $current->id, $current->category->id); header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $current->id); } } ?> +<form method="post"> + <textarea name="post_content" rows="10" cols="50"></textarea> + <br> + <input type="submit" name="submit"> +</form> +</body> +</html> |