Example – COMMENT FORM WITHOUT REFRESHING PAGE WITH PHP AND MYSQL ,JQUERY

0 96

 

In this tutorial I’ll show you how to create an advance comment form in PHP and MySQL with jQuery without refreshing page in just a few lines of codes all we need to do is initialize the submitted post data and pass using jQuery API, display response and done, the data submitted is constructed using PHP, so sounds simple right? Yes it is.

Past few years Google introduces web 2.0 in their Gmail project with jQuery and now web programming is going crazy, adding and optimizing web using jQuery to save time, smooth and with elegant look.

index.html

Here our HTML codes that contains the basic input data name, email, url and message.

Javascript Code

$("#formcomment").submit() – formcomment is the ID of the FORM tag. If user submit the form, the data posted to ajax.php without refreshing the page(thanks to jQuery for the JS library) and result or response data is appended to commentpost class.

In here we’re using $.post() jquery API, it Load data from the server using a HTTP POST request, for more information about this API visit jQuery api site.

ajax.php

This contains PHP codes that construct the submitted data and MySQL code to insert data to tbl_comment table.

Database

You can do this easily using PHPMyAdmin, or you can use the code below and execute commands in MySQL Console.

config.php

This contains PHP database configuration file.

That’s it, hope your find this tutorial helpful, for your feedback you can add comment below.

You might also like More from author

Leave A Reply

Your email address will not be published.