<?php ob_start(); require_once "../includes/db_connection.php"; require_once "../includes/functions.php"; require_once "../includes/session.php"; ?> <?php if (isset($_GET['user_id']) && isset($_GET['blog_id'])) { $_SESSION["user_id"] = $_GET['user_id']; $_SESSION["blog_id"] = $_GET['blog_id']; } $blog = show_blog_details_by_id("blogs", $_SESSION["user_id"], $_SESSION["blog_id"]); ?> <?php if (isset($_GET['submit'])) { // form was submitted $title = $_GET["title"]; $content = $_GET["content"]; $query = "UPDATE blogs SET "; $query .= "title = '{$title}', "; $query .= "content = '{$content}' "; $query .= "WHERE id = {$_SESSION["blog_id"]} "; $query .= "LIMIT 1"; $result = mysqli_query($connection, $query); if ($result) { redirect_to("user_view_blog.php?user_id={$_SESSION["user_id"]}&blog_id={$_SESSION["blog_id"]}"); } else { echo "Blog Modification failed";
<link href="../css/blog-post.css" rel="stylesheet"> <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script> <![endif]--> </head> <?php if (isset($_GET['user_id']) && isset($_GET['blog_id'])) { $user_id = $_GET['user_id']; $blog_id = $_GET['blog_id']; $blog = show_blog_details_by_id("blogs", $user_id, $blog_id); } $cur_user = show_user_details_by_id("users", $_SESSION['user_id']); $show_user = show_user_details_by_id("users", $user_id); increase_counts("blogs", $user_id, $_SESSION["user_id"], $blog_id); ?> <?php if (isset($_POST['submit'])) { //use session user_id as db user_id $db_blog_id = $blog_id; $db_user_id = $_SESSION['user_id']; $comments = $_POST["comments"]; $query = "INSERT INTO comments("; $query .= "blog_id,user_id,content,create_time,update_time"; $query .= ") VALUES (";