Sunday, 12 May 2013
Facebook StumbleUpon Twitter Google+ Pin It

Comment system with jQuery, Ajax and PHP

This time I had developed Comment system with out refreshing page with jQuery, Ajax and PHP. In this application I had implemented with gravatar image. It's is useful and simple just some lines of code.

javascript code.

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" >
$(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');
$("#flash").fadeIn(400).html('<img src="ajax-loader.gif" />Loading Comment...');
type: "POST",
url: "commentajax.php",
data: dataString,
cache: false,
success: function(html){
$("ol#update li:last").fadeIn("slow");
}return false;
}); });

Contains HTML code here class timeline li{display:none}
<ol id="update" class="timeline">
<div id="flash"></div>
<div >
<form action="#" method="post">
<input type="text" id="name"/>Name<br />
<input type="text" id="email"/>Email<br />
<textarea id="comment"></textarea><br />
<input type="submit" class="submit" value=" Submit Comment " />

Contains PHP and HTML code.
$lowercase = strtolower($email);
$image = md5( $lowercase );
mysql_query("SQL Comment table insert statement");
else { }

<li class="box">
<img src="
<?php echo $image; ?>"/>
<?php echo $name;?><br />
<?php echo $comment; ?>

Parthiv Patel
Bhaishri Info Solution
Sr. PHP Developer
Limdi Chowk, AT PO. Nar, Di. Anand
Nar, Gujarat
DOB: 12/24/1986

No comments: