diff options
author | cflip <36554078+cflip@users.noreply.github.com> | 2021-05-15 09:15:58 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-15 09:15:58 -0600 |
commit | 45acfc48b3dd80b945a1501edea9ad4faa700c0f (patch) | |
tree | 87319e8b64789564e5d9ae227361593c419d905b /viewthread.php | |
parent | 87b1dfd1f77b08915ee5e905da45e316ba2c0e7d (diff) | |
parent | 2b03ca63d06ec5da45c887ef7cb3daa35a8642f7 (diff) |
Merge pull request #16 from cflip/h5p9sl
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> |