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

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 />";
}
?>