Save HTML form Using Jquery
Posted in: Jquery, PHP

Save HTML Form Using Jquery and PHP Without Page Refresh

Hello friends hope you all are doing good and please be safe at your home in this pandemic situation. In the previous tutorial we have used Ajax to save the HTML form without refresh.  Now in this tutorial we will use the Jquery to send the data to our PHP script.

In Jquery we can use 2 methods for getting the HTML form data without refresh. We have serialize() function to get all the data or we can use the normal method to get the data like – var mydata={“name”:$(‘#id’).val()} you can add more data by comma separate.




For sending the data we will use $.POST(), $.GET() etc. These methods takes multiple parameters like – url, data, result.

Yoururl means where you want to send your data. Your PHP page where you will do the other processing like sending mail or saving the data to the database.

Yourdata means data which was filled in the HTML form. And you can get the data by using any above discussed methods.

If you want to save form using php then read it here.

So lets start How to Save HTML Form Using Jquery

First of all we will divide it into 3 parts 1 is HTML form and 2nd is Jquery for getting the values and sending those values to PHP and final is PHP part to get the values and save it to the database. Now we will start our working from 1st part which is creating HTML form.

Include the CSS and Jquery by using CDN

HTML Form (Use bootstrap for this)




In the above code we have created the HTML form for filling out the data. Now we will written down the Jquery part to transfer this data to our PHP page.

In the above code you can see that we are transferring our data to our PHP page you can see the url variable. In the “formdetails” variable we are getting our whole form values. We have used the post method so we will transfer the data using POST to our PHP so while getting the data we have to use $_POST in our PHP.

PHP Script (postvalues.php)

Hope you like our tutorial if you have any advice then please comment below.

~ Stay Home Be Safe Use Mask ~

Leave a Reply

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