Hi guys,
In this code you will learn how to crate a Post and comment script which is very useful when you are developing a social networking site or any project that you want to put a Post and a comment system. Its design is from twitter bootstrap. Hope that you will like this code for more question email me at
[email protected].
Thank you.
Database name: post in db folder
Sample code:
<?php
include('header.php');
?>
<body>
<br>
<br>
<div class="container">
<form class="form-horizontal" method="POST">
<div class="control-group">
<div class="controls">
<textarea rows="3" name="post_content" class="span6" placeholder="Whats on Your Mind"></textarea>
</div>
</div>
<div class="control-group">
<div class="controls">
<button name="post" type="submit" class="btn btn-info"><i class="icon-share"></i> Post</button>
</div>
</div>
<div class="control-group">
<div class="controls">
<table class="table table-bordered">
<thead>
</thead>
<tbody>
<?php
$id=$row['post_id'];
?>
<tr>
<td><?php echo $row['content']; ?></td>
<td width="50"><?php
?>
<a href="#<?php echo $id; ?>" data-toggle="modal"><i class="icon-comments-alt"></i> <span class="badge badge-info"><?php echo $count; ?></span></a></td>
<td width="40"><a class="btn btn-danger" href="delete_post.php<?php echo '?id='.$id; ?>"><i class="icon-trash"></i></a></td>
</tr>
<!-- Modal -->
<div id="<?php echo $id; ?>" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header"> </div>
<div class="modal-body">
<!----comment -->
<form method="POST">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<textarea rows="3" name="comment_content" class="span6" placeholder="Your Comment Here"></textarea>
<br>
<br>
<button name="comment" type="submit" class="btn btn-info"><i class="icon-share"></i> Comment</button>
</form>
<br>
<br>
<div class="alert alert-success"><?php echo $comment_row['content']; ?></div>
<?php } ?>
<!--- end comment -->
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
</div>
<?php } ?>
</tbody>
</table>
</div>
</div>
</form>
</div>
<?php
if(isset($_POST['post'])){
$post_content=$_POST['post_content'];
}
?>
<?php
if(isset($_POST['comment'])){
$comment_content=$_POST['comment_content'];
$post_id=$_POST['id'];
}
?>
</body>
</html>
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.