Tuesday, February 27, 2018

How To Insert With PHP, Jquery And AJAX

Leave a Comment

Hi Everyone, In this tutorial we will see step by step how to insert data into mysql database with PHP, Jquery and AJAX without refresh the page. in order to use AJAX method I have used Jquery library to access the inbuilt capabilities of AJAX. Behind the scene i have used Jquery AJAX method to send the all form data to server, in this case to a PHP page that will contain the script to save the data to database and send back the success message to AJAX call back function without reload the page. 

Step 1 - Mysql Database

Create Database and name it as insert, Once you create your database table, do not forget to make the connection with database.

Step 2 - Connect With Database

Here we will create the database connection, i have been used mysqli object oriented version in order to connect with database. 

  Step 3 - HTML Form Page

create the html form save it as index.php. if you wish you can divide the page into header and footer page, that will make your page more convenience. 

Make sure here we are not going to use the form method and action in order to send the credential to server, instead we goin to use AJAX to send the credential to server, for that leave as blank action attribute and method attribute. 

Step 4 - Create insert page with php extension
Create insert.php and add bellow codes. 

Step 5 - Create insert.js page

I hope this tutorial will give you a basic idea of creating insert with php without reload the page. if you have any doubt feel free to contact me via - webriderat@gmail.com 

If You Enjoyed This, Take 5 Seconds To Share It


Post a Comment