Submit Form without Page Refresh using jQuery, Ajax, PHP

By | December 23, 2016

In this post we are going to check how to submit form without page refresh using jQuery ajax and php.¬†For this tutorial we are going to use simple script in jQuery which uses ajax() function to send form data to the next page using post() method. We will input user details and submit php form using ajax. And you will notice that URL of the page won’t change this is a very robust feature of jQuery Ajax.

form submit without page refresh


Download Script


Ajax Login system with PHP

Simple Login System with PHP


Submit Form without Page Refresh using jQuery, Ajax, PHP



`first_name` varchar(55) NOT NULL,
`last_name` varchar(55) NOT NULL,
`email` varchar(55) NOT NULL,
`contact` int(10) NOT NULL
) ;




In this form we are collecting four input fields from the user and are submitting data to submit_process.php using ajax. It will then insert details in the database.

<!DOCTYPE html>

<link rel="stylesheet" href="">

<script src=""></script>

<script src=""></script>



position: absolute;
width: 220px;
padding: 10px;
border: 3px solid green;
margin: 1;




<nav class="navbar navbar-default">

<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->

<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<a class="navbar-brand" href="#">TechPlugg Dashboard</a>

<ul class="nav navbar-nav navbar-right">


<!-- /.navbar-collapse -->

<!-- /.container-fluid -->


<h1>Welcome to TechPlugg</h1>

We are a Tech Blog with Programming tutorials

<div class="ajax_response">

<form id="registration_form" align="center">
<div id ="main">
<input type="text" name="first_name" id="first_name" placeholder="Enter first Name" /><br/><br/><br/>
<input type="text" name="last_name" id="last_name" placeholder="Enter last Name"/><br/><br/><br/>
<input type="text" name="email" id="email" placeholder="Enter your Email" /><br/><br/><br/>
<input type="text" name="contact" id="contact" placeholder="Enter your contact number" /><br/><br/><br/>

<center><input type="submit" value="Submit" id="btn-register" name="btn-register" class="btn btn-primary"/></center>

<script src=""></script>

<script type="text/javascript">

$(document).ready(function() {
type: "POST",
url: "submit_process.php",
data: $("#registration_form").serialize(),
success: function(response) {

$('#registration_form').fadeOut('slow', function(){
return false;



Submit process simply inserts data in the database and displays the input provided by user.

include_once 'db.php';

 $first_name = $_POST['first_name'];
 $last_name = $_POST['last_name'];
 $email = $_POST['email'];
 $contact = $_POST['contact'];

 $query = "INSERT INTO details(first_name,last_name,email,contact) VALUES('$first_name','$last_name','$email','$contact')";

 echo " <table class='table table-condensed' align='center' >";

 <td>First Name</td>
 <td><?php echo $first_name ?></td>
 <td>Last Name</td>
 <td><?php echo $last_name ?></td>
 <td><?php echo $email; ?></td>
 <td>Contact No</td>
 <td><?php echo $contact; ?></td>
 echo "</table>";


Also check how to upload image file in PHP.

I hope you liked this post. Feel free to share it!