<html>
<head>
<title>Submit Form Using AJAX PHP and javascript</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
function myFunction() 
{
var name = document.getElementById("name").value;
var email = document.getElementById("email").value;

// Returns successful data submission message when the entered information is stored in database.
var dataString = 'name1=' + name + '&email1=' + email;
if (name == '' || email == '' ) {
alert("Please Fill All Fields");
} 
else 
{
// AJAX code to submit form.
$.ajax({
    type: "GET",
    url: "ajaxf.php",
    data: dataString,
    success:function(html){
           update_div.html(html);
	}
  });
  return false;
}
}
</script>
</head>
<body>
<?php
require("dbconnect.php");
?>
<div id="mainform">
<div class="innerdiv">
<h2>Submit Form Using AJAX,PHP and javascript</h2>
<!-- Required Div Starts Here -->
<form id="form" name="form">
<h3>Fill Your Information!</h3>

<label>Name :</label>
<input id="name" type="text">
<label>Email :</label>
<input id="email" type="text">

<input id="submit" onclick="myFunction()" type="button" value="Submit">
</div>
</form>
</div>
<div id="update_div">
<?php echo "xxxxxxxxxxxxxx";
if(isset($_GET["name1"])){ echo $_GET["name1"];}
?>
</div>

</body>
</html>