Thursday 20 August 2015

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.

 

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



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

OUTPUT IMAGE

that's it comment system is ready.

If you have any problem regarding this tutorial configuration please feel free to comment we love to answer your queries.

4 comments:

  1. Thanks for this module, it's a great way to reduce the time it takes to develop this pattern.

    ReplyDelete

  2. 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
  3. PHP is open source which any one can use. The PHP website specialists are giving specific assistance and continually reviving the inside PHP functionalities.Why use Laravel

    ReplyDelete
  4. Be that as it may, issues engaged with presenting patent rights to software are much more mind boggling than taking out copyrights on them. itools 4 crack download

    ReplyDelete