I have visited the following Link
Now i have 2 Sample files Contents of test2.php
<!DOCTYPE html>
<html>
<head>
<title> Form </title>
</head>
<body>
<?php include_once("test.php"); ?>
</body>
</html>
Content of test.php
<?php
if (isset($_POST['submit'])) {
$arr=array();
foreach ($_POST as $key => $value) {
$arr[$key]=$value;
}
print_r($arr);
}
?>
<!DOCTYPE html>
<html>
<head>
<title> Form </title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<link rel="stylesheet" href="css/main.css" />
</head>
<body>
<div id="content" id="login_form">
<form method="post" id="f1" name="f1" action="test.php">
<table>
<tr>
<td>Name :</td><td><input type="text" name="name"/></td>
</tr>
<tr>
<td>Register Number :</td><td><input type="text" name="regno"/></td>
</tr>
<tr>
<td>Date of Birth :</td><td><input type="text" name="dob"/></td>
</tr>
<tr>
<td><input type="submit" id="b1" name="submit" value="Submit" style="font-size:16px;"/></td>
</tr>
</table>
</form>
</div>
<script>
$('#f1').submit(function() {
$.ajax({
data: $(this).serialize(),
type: $(this).attr('post'),
url: $(this).attr('test.php'),
success: function(response) {
$('#content').html(response);
}
});
return false;
});
</script>
</body>
</html>
test2.php displays the form.I want to display the values entered in the form and the form
after I click submit but I keep seeing the form only.
is it because $_POST is empty or because I have made mistakes in the structure of the page itself?
Edit : I want the result of the form submit loaded in test2.php page.