Reloaded: Facebook Style Wall Posting and Comments System using jQuery PHP and Ajax.

Facebook style wall posting and commenting system. Try a new reloaded version of demo which is almost similar to facebook style.
My previous facebook style posting system was not so much like original facebook posting style and also there is no commenting system So I created this tutorial again to complete the commenting system and I tried my best to give my dear users a complete posting script with comments system. Facebook is now a days top social networking site. So I have created some tutorials similar to facebook. Youtube style rating is also very popular tutorial on this blog. Hope you like it.
Waiting for your feed back to make it more good.
Database Structure
CREATE TABLE `facebook_posts` (
`p_id` int(11) NOT NULL auto_increment,
`f_name` varchar(50) NOT NULL,
`post` varchar(255) NOT NULL,
`f_image` varchar(50) NOT NULL,
`date_created` int(11) NOT NULL,
`userip` varchar(200) NOT NULL,
PRIMARY KEY (`p_id`)
)
CREATE TABLE `facebook_posts_comments` (
`c_id` int(11) NOT NULL auto_increment,
`userip` varchar(200) NOT NULL,
`comments` text NOT NULL,
`date_created` int(11) NOT NULL,
`post_id` int(11) NOT NULL,
PRIMARY KEY (`c_id`)
)
I have used ip check to make user restricted to there posts or comments. They can only there postings.
Two new function missed in source files. One for making links clickable and other for removing tags etc.
function clickable_link($text = '')
{
$text = preg_replace('#(script|about|applet|activex|chrome):#is', "\1:", $text);
$ret = ' ' . $text;
$ret = preg_replace("#(^|[n ])([w]+?://[w#$%&~/.-;:=,?@[]+]*)#is", "\1\2", $ret);
$ret = preg_replace("#(^|[n ])((www|ftp).[w#$%&~/.-;:=,?@[]+]*)#is", "\1\2", $ret);
$ret = preg_replace("#(^|[n ])([a-z0-9&-_.]+?)@([w-]+.([w-.]+.)*[w]+)#i", "\1\2@\3", $ret);
$ret = substr($ret, 1);
return $ret;
}
function checkValues($value = '')
{
$value = trim($value);
if (get_magic_quotes_gpc())
{
$value = stripslashes($value);
}
$value = strtr($value,array_flip(get_html_translation_table(HTML_ENTITIES)));
$value = strip_tags($value);
$value = mysql_real_escape_string($value);
$value = htmlspecialchars($value);
return $value;
}
Here is the comment box focus code below. When we click on a comment box text area.
//onfocus
$('.commentMark').livequery("focus", function(e){
var parent = $(this).parent();
$(".commentBox").children(".commentMark").css('width','337px');
$(".commentBox").children("a#SubmitComment").hide();
$(".commentBox").children(".CommentImg").hide();
var getID = parent.attr('id').replace('record-','');
$("#commentBox-"+getID).children("a#SubmitComment").show();
$('.commentMark').css('width','300px');
$("#commentBox-"+getID).children(".CommentImg").show();
});
Submit comment code.
// I used livejquery plugin to work my code effective for dynamic elements.
$('a.comment').livequery("click", function(e){
var getpID = $(this).parent().attr('id').replace('commentBox-','');
var comment_text = $("#commentMark-"+getpID).val();
if(comment_text != "Write a comment...")
{
$.post("add_comment.php?comment_text="+comment_text+"&post_id="+getpID, {
}, function(response){
$('#CommentPosted'+getpID).append($(response).fadeIn('slow'));
$("#commentMark-"+getpID).val();
});
}
});
Get more records code
// I used livejquery plugin to work my code effective for dynamic elements.
$(‘a.more_records’).livequery(“click”, function(e){
var next = $(this).attr(‘id’).replace(‘more_’,”);
$.post(“posts.php?show_more_post=”+next, {
}, function(response){
$(‘#bottomMoreButton’).remove();
$(‘#posting’).append($(response).fadeIn(’slow’));
});
});
Delete comment code:
//deleteComment
$('a.c_delete').livequery("click", function(e){
if(confirm('Are you sure you want to delete this comment?')==false)
return false;
e.preventDefault();
var parent = $(this).parent();
var c_id = $(this).attr('id').replace('CID-','');
$.ajax({
type: 'get',
url: 'delete_comment.php?c_id='+ c_id,
data: '',
beforeSend: function(){
},
success: function(){
parent.fadeOut(200,function(){
parent.remove();
});
}
});
});
add_comments.php File:
0)
echo date('F d Y', $rows['date_created']);
elseif($days2 == 0 && $hours == 0 && $minutes == 0)
echo "few seconds ago";
elseif($days2 == 0 && $hours == 0)
echo $minutes.' minutes ago';
else
echo "few seconds ago";
?>
Delete
post.php File:
\2", $ret);
$ret = preg_replace("#(^|[n ])((www|ftp).[w#$%&~/.-;:=,?@[]+]*)#is", "\1\2", $ret);
$ret = preg_replace("#(^|[n ])([a-z0-9&-_.]+?)@([w-]+.([w-.]+.)*[w]+)#i", "\1\2@\3", $ret);
$ret = substr($ret, 1);
return $ret;
}
$next_records = 10;
$show_more_button = 0;
if(checkValues($_REQUEST['value']))
{
$userip = $_SERVER['REMOTE_ADDR'];
echo "INSERT INTO facebook_posts (post,f_name,userip,date_created) VALUES('".checkValues($_REQUEST['value'])."','99Points','".$userip."','".strtotime(date("Y-m-d H:i:s"))."')";
mysql_query("INSERT INTO facebook_posts (post,f_name,userip,date_created) VALUES('".checkValues($_REQUEST['value'])."','99Points','".$userip."','".strtotime(date("Y-m-d H:i:s"))."')");
$result = mysql_query("SELECT *,
UNIX_TIMESTAMP() - date_created AS TimeSpent FROM facebook_posts order by p_id desc limit 1");
}
elseif($_REQUEST['show_more_post']) // more posting paging
{
$next_records = $_REQUEST['show_more_post'] + 10;
$result = mysql_query("SELECT *,
UNIX_TIMESTAMP() - date_created AS TimeSpent FROM facebook_posts order by p_id desc limit ".$_REQUEST['show_more_post'].", 10");
$check_res = mysql_query("SELECT * FROM facebook_posts order by p_id desc limit ".$next_records.", 10");
$show_more_button = 0; // button in the end
$check_result = mysql_num_rows(@$check_res);
if($check_result > 0)
{
$show_more_button = 1;
}
}
else
{
$show_more_button = 1;
$result = mysql_query("SELECT *,
UNIX_TIMESTAMP() - date_created AS TimeSpent FROM facebook_posts order by p_id desc limit 0,10");
}
while ($row = mysql_fetch_array($result))
{
$comments = mysql_query("SELECT *,
UNIX_TIMESTAMP() - date_created AS CommentTimeSpent FROM facebook_posts_comments where post_id = ".$row['p_id']." order by c_id asc"); ?>
Remove
0)
{
while ($rows = mysql_fetch_array($comments))
{
$days2 = floor($rows['CommentTimeSpent'] / (60 * 60 * 24));
$remainder = $rows['CommentTimeSpent'] % (60 * 60 * 24);
$hours = floor($remainder / (60 * 60));
$remainder = $remainder % (60 * 60);
$minutes = floor($remainder / 60);
$seconds = $remainder % 60;
?>
0)
echo date('F d Y', $rows['date_created']);
elseif($days2 == 0 && $hours == 0 && $minutes == 0)
echo "few seconds ago";
elseif($days2 == 0 && $hours == 0)
echo $minutes.' minutes ago';
else
echo "few seconds ago";
?>
Delete
delete_comments.php File:
The above code is just to show you different functionless. However you can get complete working script by downloading source above.
411 to “Reloaded: Facebook Style Wall Posting and Comments System using jQuery PHP and Ajax.”
Post comment

Categories
- AJAX (28)
- Announcement (3)
- Blogging Tips (1)
- Codeigniter (16)
- CSS (14)
- Facebook (8)
- Freelance Tips (1)
- How-To (2)
- Joomla (1)
- JQuery (51)
- Miscellaneous (3)
- Mootools (1)
- MySQL (3)
- PHP (57)
- SEO (2)
- Technology (6)
- Tutorials (17)
- Twitter (2)
- Web Design (26)
- Web Development (58)
- WordPress (3)
Popular post
- 46 Highly Responsive Admin Templates for Your Websites
- $50 PayPal Cash & 5 Premium PHP Wall Script Prizes #Giveaway
- PHP Wall Script Clone with Real Time Features __ January 2013 Release __
- Things you should know if you are a Blogger
- Top 10 Must Have Qualities of a Freelance Web Developer
- Fundamental Factors for Mobile Compatible eCommerce Hosting
- Facebook Wall Script New Version in September 2012
Recommend

its not working for me. i tried it in localhost several times but didn’t loaded at all
[...] and bigger on each click. This is an awesome and unique rating system. Hope you like. You can get facebook style comment script, facebook style extracting url data, youtube style share button, facebook style profile edit, Ajax [...]
share button is not working.Nothing get posted after clicking on share button.
Hi Zeeshan Rasool, I’m wprking on a project to develop a social networking site.
If interested to work on it, just contact.
mrehman1981@gmail.com
Hi Zeeshan,
You did a great job and congratulations for the blog.
I have only some questions:
I have these errors even if the post is published.
Notice: Undefined index: value in / Applications / MAMP / htdocs / wall_comment / posts.php on line 35
Notice: Undefined index: show_more_post in / Applications / MAMP / htdocs / wall_comment / posts.php on line 45
as if it did not recognize the values?
I noticed a problem that occurs with firefox on MAC 18.2 or 16.0.2 where after publishing the first post if you try to click on “comment” in the first post, nothing happens.
if you press comment on old posts or charging on comment by clicking opens the form text area to write your comment.
between the old posts and new comments published on running you can see the errors that I mentioned above.
On Chrome I haven’t problem on “comment” but there are errors on line 35 and 45.
Sorry for the bother you.
Have you any idea how to fix it?
Not working..!!
If I open the same url in 2 browser and update some text in first browser it visible on in first browser, not in second browser..
in actually it should be updated in both browser immediately, but its not.
Oh my goodness! Incredible article dude! Thank you, However I am encountering
issues with your RSS. I don’t know the reason why I cannot join it. Is there anybody having similar RSS problems? Anyone that knows the solution will you kindly respond? Thanx!!
same question that Zeeshan to you
I have these errors even if the post is published.
Notice: Undefined index: value in / Applications / MAMP / htdocs / wall_comment / posts.php on line 35
Notice: Undefined index: show_more_post in / Applications / MAMP / htdocs / wall_comment / posts.php on line 45
Have you any idea how to fix it?
Notice: Undefined index: value
Notice: Undefined index: show_more_post
please help me!!
The reason you guys are getting the undefined index error is because nothing has been posted yet. To fix that, use isset like:
if (isset($_POST['value']) && checkValues($_POST['value'])) { … }
Basically, you need to check if the variable has been submitted.
I’m currently making changes to this where it uses a logged in user instead of the ip.
I am really impressed with your writing skills as well as with the layout on your weblog. Is this a paid theme or did you customize it yourself? Anyway keep up the excellent quality writing, it’s rare to see a nice blog like this one these days..
| Guidelines For Juicer Reviews Tactics