Live Demo
javascript code.
comment.php
Contains HTML code here class timeline li{display:none}
commentajax.php
Contains PHP and HTML code.
{
$name=$_POST['name'];
$email=$_POST['email'];
$comment=$_POST['comment'];
$lowercase = strtolower($email);
$image = md5( $lowercase );
mysql_query("SQL Comment table insert statement");
}
else { }
<?php echo $image; ?>"/>
<?php echo $name;?><br />
<?php echo $comment; ?>
javascript code.
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" >
$(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');
}
$("#flash").show();
$("#flash").fadeIn(400).html('<img src="ajax-loader.gif" />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;
}); });
</script>
<script type="text/javascript" >
$(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('<img src="ajax-loader.gif" />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;
}); });
</script>
comment.php
Contains HTML code here class timeline li{display:none}
<ol id="update" class="timeline">
</ol>
<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 " />
</form>
</div>
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>
6 comments:
Thanks for sharing these niche piece of coding to our knowledge. Here, I had a solution for my inconclusive problems & it’s really helps me a lot keep updates…
Regards,
PHP Training in Chennai
Thanks for sharing this niche useful informative post to our knowledge, Actually SAP is ERP software that can be used in many companies for their day to day business activities it has great scope in future so do your SAP Training in Chennai
Regards,
SAP course in chennai|SAP Institutes in Chennai|sap training in Chennai|SAP SD Training In Chennai
Well post, Thanks for sharing this to our vision. In recent day’s customer relationship play vital role to get good platform in business industry, Sales force crm tool helps you to maintain your customer relationship enhancement.
Regards,
Salesforce training in Chennai|Salesforce training institute in Chennai|Salesforce courses in Chennai
Nice Article! Mostly I have gathered knowledge from the blogger, because its provides more information over the books & here I can get more experienced skills from the professional, thanks for taking your to discussing this topic.
Regards,
cognos Training in Chennai|cognos tm1 Training in Chennai|cognos Certification
Hi Dude,
Awesome Post!!! With unique content, I really get reading interest when I am following your article, I hope I ll help many of them who looking this pretty information.
Regards,
Python Training in Chennai|Python Training Institutes in Chennai|python training chennai|FITA Academy reviews
Hi Siddhu,
Three cheers to you ! Hooray!!! I feel like I hit the jackpot on Comment system with jQuery, Ajax and PHP!
I have earlier ask for help but I still have problem with installing Mageia,
Why it is so difficult.? I have a laptop HP where I want to install some Linux to play with but I cannot find an installation that I can copy to a USB or a CD så I can install in this Laptop.
This Laptop has not internet connection yet and have a windows XP OS until now but I want to convert it to Linux.
It was cool to see your article pop up in my google search for the process yesterday. Great Guide.
Keep up the good work!
Shukran,
Abhiram
Post a Comment