// Couldn't get the information print '<div class="alert alert-danger"><p>Could not retrieve the blog post because:<br>' . mysqli_error($dbc) . '.</p> <p>The query being run was ' . $query . '</p></div>'; } } elseif (isset($_POST['post_id']) && is_numeric($_POST['post_id']) && $_POST['post_id'] > 0) { // Handle the form // Validate and secure the form data: $problem = false; if (!empty($_POST['title']) && !empty($_POST['post'])) { // prepare the values for storing: $title = mysqli_real_escape_string($dbc, trim(strip_tags($_POST['title']))); $post = mysqli_real_escape_string($dbc, base64_encode($_POST['post'])); $cat_id = $_POST['cat_id']; } else { print '<div class="alert alert-danger"><p>Please make sure you have filled out all the fields.</p></div>'; $problem = TRUE; } if (!$problem) { handle_bp('update'); display_bp('update', $title, $post, $cat_id); } // No problem } else { // No ID set print '<div class="alert alert-danger"><p>This page has been accessed in error.</p></div>'; } // End of main IF. mysqli_close($dbc); // Close the connection include 'common/footer.html'; // Include the footer
define('TITLE', 'Add Blog Post'); include 'common/header.html'; // Must sign in for access: check_access('School', 'Computing'); // Need the database connection // include(MYSQL); - use this only if you changed the path in config.php include "../config/mysql_connect.php"; // Check for a form submission: if ($_SERVER['REQUEST_METHOD'] == 'POST') { // Handle the form if (strlen($_POST['title']) > 100) { // Check title length print '<div class="alert alert-danger"> <p>Please use a short and succint title that is less than 100 characters long. You used ' . strlen($_POST['title']) . ' characters!</p> </div>'; } elseif (!empty($_POST['title']) && !empty($_POST['post'])) { handle_bp('add'); } else { // Failed to fill in the required blanks print '<div class="alert alert-danger"> <p>Please make sure you have entered both a title and your blog post.</p> </div>'; } } // End of submitted IF. display_bp('add'); ?> <?php include 'common/footer.html';