if (isset($_SESSION['username'])) {
    echo 'Hello ' . $username . '';
}
echo '<div style="border-width: 2px; border-style: solid; border-color: rgba(0, 0, 0, 0.7); " class="posts" align="left">';
$posts = post_for_comment($id);
if (count($posts)) {
    foreach ($posts as $key => $list) {
        echo $list['userpost'] . "&nbsp&nbsp&nbsp" . "<small>" . $list['stamp'] . "<br>" . $list['message'] . "</small>";
    }
}
?>
</div>
<?php 
echo '<div style="border-width: 2px; border-style: solid; border-color: rgba(0, 0, 0, 0.7); " class="posts" align="left">';
echo '<small>comments: - - -<br></small>';
$posts = post_comments($id);
if (count($posts)) {
    foreach ($posts as $key => $list) {
        echo $list['usercomment'] . "&nbsp&nbsp&nbsp" . "<small>" . $list['stamp'] . "<br>" . $list['message'] . "</small><br>";
    }
}
?>
</div>
<small>Send a comment [160 characters]</small>
<form method='post' action='add_comment.php'>
<textarea name='message' rows='4' cols='45' ></textarea>
<input type='hidden' name='idcomment' value = "<?php 
echo $id;
?>
">
<input type='submit' value='     SUBMIT     '/>
Beispiel #2
0
<aside>
<?php 
//Here I will post the original post and then have the comment form below that...
$blogs = get_page_by_id($_GET['id'], $_COOKIE['friendly']);
//heading
echo "<div class=\"content\"><h2>" . $blogs['page_name'] . "</h2>";
//author and date
echo author_date($blogs['date'], $blogs['author']);
//content
echo $blogs['content'];
//tag area: the fucntion will get all of the individual strings from the tag field
echo '<p><span class="small">Tags: ';
echo explode_tags($blogs['tags']);
echo '</span></p>';
//comments
echo post_comments($blogs['id']);
?>

<form id= "add_blog" method= "post">
  <fieldset>
    <label for= "comment" type= "text"><strong>Comment: </strong></label>
    <textarea name="comment" class="comment" tabindex= "20"  style= "resize: none; width: 490px; height: 480px; margin-top: 7px;"></textarea>
    <br />
    <br />
    <input type= "submit" name= "submit" value= "Post your comment" style="width: 350px; display: block; margin: 0 auto; font-weight: bold;"/>
  </fieldset>
</form>

</aside>

<?php 
Beispiel #3
0
<?php

session_start();
require_once 'connection.php';
if (isset($_POST["action"]) && $_POST["action"] == "post_message") {
    if (!empty($_POST["post"])) {
        post_message();
    } else {
        header("Location: wall.php");
    }
} else {
    if (isset($_POST["action"]) && $_POST["action"] == "post_comment") {
        if (!empty($_POST["comment"])) {
            post_comments();
        } else {
            header("Location: wall.php");
        }
    } else {
        if (isset($_POST["action"]) && $_POST["action"] == "delete_message") {
            delete_message();
        }
    }
}
function post_message()
{
    $post = escape_this_string($_POST["post"]);
    $query = "INSERT INTO messages (message, created_at, updated_at, user_id)\n\t\t\t\t  VALUES ('{$post}', NOW(), NOW(), {$_SESSION['user_id']})";
    if (run_mysql_query($query)) {
        header("Location: wall.php");
    }
}