Comment System using PHP and MySql
2my4edge is Loading.. Wait

Monday, May 27, 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 />";
}
?>

17 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. Thanks It works... Really...

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

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

    ReplyDelete
  10. yeah its nice

    ReplyDelete