Comment System using PHP and MySql | 2my4edge

27 May 2013

Comment System using PHP and MySql

Here we are going to see about comment system suing PHP and MySql, here it is useful to all webpage feedback system like user comments Displays at the end of all WebPages that’s what we are going to see here.
comment system image
DOWNLOAD CODE                         LIVE DEMO

The above is Sample output image,  so here we are going to create a database with values, they are like

DATABASE
database name --> downdropcomment
table name --> commenttable
table values --> name--> varchar(20)
job --> varchar (25)
message --> varchar (250)
the above is database format

CODE
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Comment system using php and mysql</title>
</head>
<body>
<form name="comment" method="post" action="comment.php" onSubmit="return validation()">
<table width="500" border="0" cellspacing="3" cellpadding="3" style="margin:auto;">
  <tr>
    <td align="right" id="one">Name :<span style="color:#F00;">*</span></td>
    <td><input type="text" name="namename" id="tnameid"></td>
  </tr>
  <tr>
    <td align="right" id="one">Work :<span style="color:#F00;">*</span></td>
    <td><input type="text" name="job" id="tjobid"></td>
  </tr>
  <tr>
    <td align="right" id="one"></td>
    <td><textarea name="message" id="tmessageid"></textarea></td>
  </tr>
  <tr>
  <td align="right" id="one"></td>
  <td><input type="submit" name="submit" id="submit" value="Submit Comment"></td>
  </tr>
</table>
</form>
</body>
</html>


FORM IMAGE
form image
And then have to create a comment insert code.
<?php
include("db.php");
if(isset($_POST['submit']))
{
 $name=$_POST['namename'];
 $job=$_POST['job'];
 $message=$_POST['message'];
 $insert=mysql_query("insert into commenttable
                (name,job,message)values
                ('$name','$job','$message')")or die(mysql_error());
 header("Location:index.php");
 }
?>

And then display the comment.
<?php
include("db.php");
$select=mysql_query("select * from commenttable");
while($row=mysql_fetch_array($select))
{
 echo "<div id='sty'>";
 echo "<img src='files/fav icon.png'"."' width='50px' 
                                                height='50px' 
                                                align='left' />";
 echo "<div id='nameid'>".$row['name']."</div>";
 echo "<div id='msgid'>".$row['message']."</div>";
 echo "</div><br />";
}
?>

129 comments:

  1. Hi guys, when I am actually willing of reading these blog post to be updated regularly. It offers fastidious stuff.
    php development company

    ReplyDelete
  2. Very good blog, great information, the site Scriptcase you find good stories too.

    ReplyDelete
  3. wow this one is cool

    ReplyDelete
  4. the PHP code is insecure, watch mysql_real_escape_string () -> http://php.net/manual/en/function.mysql-real-escape-string.php

    ReplyDelete
  5. You need to strip the html tags also. ;) Anyway nice example :)

    ReplyDelete
  6. I wonder if this is the best way to do it...

    ReplyDelete
  7. hmm very usefull tutor ..

    ReplyDelete
  8. Thanks It works... Really...

    ReplyDelete
  9. need help!!!
    code for posting a comment on corresponding blog post only (method required)

    ReplyDelete
  10. thanks a lot dude,ur tutorial was a great help,one of the simplest and best ones available online

    ReplyDelete
  11. yeah its nice

    ReplyDelete
  12. love this!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    ReplyDelete
  13. hhhhhhhhhhhhhhhhhhhhhhhhhhh

    ReplyDelete
  14. thanks ... it is perfect ...

    ReplyDelete
  15. Gud 1... Very Useful... :)

    ReplyDelete
  16. Nice Job. That was easy!

    ReplyDelete
  17. simplicity!!!!!
    we should not make life complicated... hats off Arunkumar Maha

    ReplyDelete
  18. It is good for you now web9cloud provides HTML JAVA languges. Our "Show PHP" tool makes it easy to learn PHP, it shows both the PHP source code and the HTML output of the code.

    ReplyDelete
  19. super sir you are the Best and
    sir i want comment system in my website on each page plzzz help me what i do

    ReplyDelete
  20. it work. but how can I create reply for each comment.really needed. Thank you

    ReplyDelete
  21. You'll need web request for the virtual system to attract consumers by providing user-friendly in addition to user friendly products and services. Each of our excited characteristics associated with delevering upright, administration answer by which many of us develop portability, suitability, scalability in addition to User friendliness to increase user friendly encounter.php

    ReplyDelete
  22. I was not able to find any proper course on internet marketing.Atlast i have found one

    ReplyDelete
  23. How to make comments fall below the textbox? When someone posts a comment, it is being placed above the text box can we change it to post the comments bellow the text box?

    ReplyDelete
  24. asdasdasdadsadsadasdasd

    ReplyDelete
  25. Shit code. It's like we back to 1999

    ReplyDelete
  26. Coding is much more safer than other way of creating page.

    ReplyDelete
  27. Pretty nice and good piece of code

    ReplyDelete
  28. Like this blog so simple and ncie piece of code

    ReplyDelete
  29. very nice and informative thanks for sharing

    ReplyDelete
  30. Now tutorial of comment system. How to filter spam comment in my website? Do you have any solution?

    ReplyDelete
  31. can someone send me the code of multilevel comment in php using ajax

    ReplyDelete
  32. Awesome very good code if you want more code visit www.phptpoint.com

    ReplyDelete
  33. Great article. you shared very informative post. Thanks!
    web designing courses in chennai

    ReplyDelete
  34. spaaaaaaaaaaaaaaaaaaaaaaammmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm

    ReplyDelete
  35. spaaaaaaaaaaaaaaaaaaaaaaaaaammmmmmmmmmmmmmmmmmmm....!!!!!!!!!!!!!!!
    ahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh

    ReplyDelete
  36. what about following code Arunkumar..?
    $(document).ready(function(){
    $("#showHere").emotions();
    $("#tnameid").focus();
    $("#submit").click(function(){
    var sample = $("#tnameid").val();
    var sample1 = $("#tjobid").val();
    var sample2 = $("#tmessageid").val();
    $("#showHere").prepend(""+""+sample+""+""+sample2+"
    ").emotions();

    $("#tnameid").val('');
    $("#tjobid").val('');
    $("#tmessageid").val('');
    $("#tnameid").focus();


    });

    });
    add above code to your post with explanation.

    ReplyDelete
  37. What about spaaaaaaaaaaaaaaaaaaammmmmmmmmmmmm......!!!!!!!!!!!!!!

    ReplyDelete
  38. Please don't spaaaaaaaaaaaaaaaaaammmmmmmmmmmmmmmmmm.....!!!!!!!!!!!!

    ReplyDelete
  39. enemy inside blanket

    ReplyDelete
  40. i want to display only 5 comments in a page..so how can i do that.

    ReplyDelete
    Replies
    1. Add limit 5 in end of select statement.
      Ex: Select*from commenttable limit 5

      Delete
  41. Gravatar is a wonderful tool to comment on blogs and posts and get your avatar displayed

    ReplyDelete
  42. Wow!! What a great blog!! I really liked your article and appreciate your work. I have found this article while searching on internet and I would recommend this to everyone. PHP online tutorial

    ReplyDelete
  43. Usefully content using in this blog !!!

    PHP Training in Noida

    ReplyDelete
  44. this is helpfull body thxs

    ReplyDelete
  45. Thanks...
    Thanks...

    ReplyDelete
  46. Great Post thanks for sharing ! !!
    http://www.cetpainfotech.com/technology/php-training

    ReplyDelete
  47. Such a great Info !! Thanks for the sharing !! http://www.cetpainfotech.com/technology/Php-training

    ReplyDelete
  48. That is the help full for us !!
    http://www.cetpainfotech.com/technology/php-training

    ReplyDelete
  49. This information you provided in the blog that is really unique I love it!! Thanks for sharing such a great blog. Keep posting..
    PHP training in Gurgaon
    PHP course in Gurgaon
    PHP training institute in Gurgaon

    ReplyDelete
  50. I read this article. I think You put a lot of effort to create this article. I appreciate your work.
    Dissertation Writing Services

    ReplyDelete
  51. To have a good and secure website, you should go with PHP development. I like your infomation that you provided in this section. Therefore, i am recently connected with PHP development comany

    ReplyDelete
  52. No doubt in it that you are always providing us such kind of useful information. Please visit: TBI Technologies

    ReplyDelete

  53. Purchasers over the world lean toward India as the middle moment that it comes to PHP software engineers as they are effective enough to give rising stages to the proprietors Top Expert Cakephp Developers

    ReplyDelete

^