diff options
-rw-r--r-- | create_thread.php | 29 | ||||
-rw-r--r-- | register.php | 4 | ||||
-rw-r--r-- | styles/style.css | 85 |
3 files changed, 61 insertions, 57 deletions
diff --git a/create_thread.php b/create_thread.php index 3f15f63..51bfe10 100644 --- a/create_thread.php +++ b/create_thread.php @@ -39,7 +39,6 @@ if (!isset($_SESSION['signed_in'])) { <textarea name="post_content"></textarea><br> <input type="submit" name="submit"> </form> -</section> <?php include_once 'includes/db_inc.php'; @@ -66,8 +65,9 @@ function create_post($dbc, $post_content, $post_thread, $post_author) { } mysqli_stmt_bind_param($stmt, "sii", $post_content, $post_thread, $post_author); - mysqli_stmt_execute($stmt); + $result = mysqli_stmt_execute($stmt); mysqli_stmt_close($stmt); + return $result; } function validate($data) { @@ -78,22 +78,29 @@ function validate($data) { } if ($_SERVER['REQUEST_METHOD'] == 'POST') { + $post_result = NULL; $post_content = validate($_POST['post_content']); $thread_subject = validate($_POST['thread_subject']); $thread_cat = validate($_POST['thread_cat']); $user_id = validate($_SESSION['user_id']); - create_thread($dbc, $thread_subject, $thread_cat, $user_id); - $thread_id = mysqli_insert_id($dbc); - create_post($dbc, $post_content, $thread_id, $user_id); - - if (!$post_result) { - echo 'An error occurred creating your post: ' . mysqli_error($dbc); + // Disallow empty thread subjects + if (empty($thread_subject) or !$thread_subject) { + echo '<br>Thread subject cannot be empty.'; + } else { + create_thread($dbc, $thread_subject, $thread_cat, $user_id); + $thread_id = mysqli_insert_id($dbc); + $post_result = create_post($dbc, $post_content, $thread_id, $user_id); + if (!$post_result) { + echo 'An error occurred creating your post: ' . mysqli_error($dbc); + } else { + header("Location: thread.php?id=" . $thread_id); + } } - - header("Location: thread.php?id=" . $thread_id); } ?> -<?php include_once 'footer.php';?>
\ No newline at end of file +</section> + +<?php include_once 'footer.php';?> diff --git a/register.php b/register.php index a318170..efa4486 100644 --- a/register.php +++ b/register.php @@ -68,7 +68,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { $user_pass = $_POST['user_pass']; $pass_check = $_POST['user_pass_check']; - if (preg_match("/^[a-zA-Z0-9\W]*$/", $user_name) === false) { + if (preg_match("/^[a-zA-Z0-9\W]*$/", $user_pass) === false) { $errors[] = "Password contains invalid characters!"; } @@ -104,4 +104,4 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { </section> -<?php include_once 'footer.php';?>
\ No newline at end of file +<?php include_once 'footer.php';?> diff --git a/styles/style.css b/styles/style.css index c9fd7ae..e0b7358 100644 --- a/styles/style.css +++ b/styles/style.css @@ -1,33 +1,59 @@ body { background-color: #222; text-align: center; + + font-family: sans-serif; + font-size: 10pt; } -#title { - color: #F1F3F1; - margin: 20px; +nav, section, table { + background-color: white; + border: 1px solid black; + text-align: left; + margin-top: 10px; + margin-bottom: 10px; } -#wrapper { - width: 900px; - margin: 0 auto; +section { + padding: 15px; +} + +footer { + font-size: 65%; + color: #999; + text-align: left; + display: inline-block; + width: 100%; } table { border-collapse: collapse; width: 100%; - background-color: #fff; - border: 1px solid #000; - float: left; padding: 20px 30px; text-align: left; } -nav { - background-color: white; - margin-bottom: 15px; +th { + background-color: #078; + color: white; border: 1px solid black; + padding: 0.25em; +} + +form { text-align: left; + padding: 5px 5px 5px 50px; + display: inline-block; +} + +#title { + color: #eee; + margin: 20px; +} + +#wrapper { + width: 900px; + margin: 0 auto; } #user { @@ -41,23 +67,6 @@ nav { max-height: 600px; } -section { - background-color: white; - padding: 15px; - margin-bottom: 15px; - text-align: left; -} - -section h1 { - color: black; -} - -form { - text-align: left; - padding: 5px 5px 5px 50px; - display: inline-block; -} - nav a { background-color: #00728B; border: 1px solid black; @@ -87,12 +96,6 @@ table a:hover { text-decoration: none; } -th { - background-color: #00728B; - color: #F0F0F0; - border: 1px solid black; -} - h1, h4 { margin-top: 2px; margin-bottom: 10px; @@ -103,15 +106,9 @@ td { border: 1px solid black; } -h3 {margin: 0; padding: 0;} - -footer { - font-size: 65%; - margin-top: 6px; - color: #999; - text-align: left; - display: inline-block; - width: 100%; +h3 { + margin: 0; + padding: 0; } textarea { |