Comment system with jQuery, PHP AND MYSQL

Sharing is caring!

This time we are set to improve Comment framework without invigorating page with jquery, Ajax and Php. In this requisition we had actualized with gravatarimage. It’s is helpful and basic just a few lines of code. Examine the live demo impact.

javascript code.
http://jquery.js

$(function() {
$(“.submit”).click(function()
{
var name = $(“#name”).val();
var email = $(“#email”).val();
var comment = $(“#comment”).val();
var dataString = ‘name=’+ name + ‘&email=’ + email + ‘&comment=’ + comment;
if(name==” || email==” || comment==”)
{
alert(‘Please Give Valid Details’);
}
else
{
$(“#flash”).show();
$(“#flash”).fadeIn(400).html(‘Loading Comment…’);
$.ajax({
type: “POST”,
url: “commentajax.php”,
data: dataString,
cache: false,
success: function(html){
$(“ol#update”).append(html);
$(“ol#update li:last”).fadeIn(“slow”);
$(“#flash”).hide();
}
});
}return false;
}); });

C
omment.php

Contains HTML code here class timeline li{display:none}
<ol id=”update” class=”timeline”>
</ol>

Name
Email

commentajax.php
Contains PHP and HTML code.
<?php
if($_POST)
{
$name=$_POST[‘name’];
$email=$_POST[’email’];
$comment=$_POST[‘comment’];
$lowercase = strtolower($email);
$image = md5( $lowercase );
mysql_query(“SQL Comment table insert statement”);
}
else { }
?>

<li class=”box”>
<img src=”http://www.gravatar.com/avatar.php?gravatar_id=
<?php echo $image; ?>”/>
<?php echo $name;?><br />
<?php echo $comment; ?>
</li>

Download Source Code here

4 thoughts on “Comment system with jQuery, PHP AND MYSQL

Leave a Reply

Your email address will not be published. Required fields are marked *

Got Project on mind? Let's ConnectContact Us

Secured By miniOrange