I am adding a form to my wordpress with a custom php page template
Below is my wordpress page template php code:
<?php
/*
Template Name: Form
*/
?>
<?php get_header(); ?>
<div id="content">
<h1 class="page-title"><?php the_title(); ?></h1>
<div class="entry">
Welcome <?php echo $_POST["fname"]; ?>!<br>
You are <?php echo $_POST["age"]; ?> years old.
</div> <!--end .entry-->
</div> <!--end #content-->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
And I am including the following code from my page which shows the form
<form action="http://127.0.0.1:4001/wordpress/script" method="post">
Name: <input type="text" name="fname">
Age: <input type="text" name="age">
<input type="submit">
</form>
This will show the form data in a new page instead of showing the result on the same page. How can I show the result on same page?
I would like to have something like this: