I am trying to submit form and get that data in same page when i used the_permalink i am getting page not found.
I used this code:
<?php
/*
Template Name:testing
*/
if(isset($_POST["name"]))
{
echo $_POST["name"];
}
?>
<form action="<?php the_permalink(); ?>" method="POST">
<input type="text" name="name" id="name">
<input type="submit" value="submit">
</form>
I am trying to submit form and get that data in same page when i used the_permalink i am getting page not found.
I used this code:
<?php
/*
Template Name:testing
*/
if(isset($_POST["name"]))
{
echo $_POST["name"];
}
?>
<form action="<?php the_permalink(); ?>" method="POST">
<input type="text" name="name" id="name">
<input type="submit" value="submit">
</form>
Share
Improve this question
edited Nov 9, 2019 at 21:56
Marco Panichi
4708 silver badges19 bronze badges
asked Aug 3, 2015 at 5:45
madumadu
832 gold badges3 silver badges8 bronze badges
1 Answer
Reset to default 6Do not use any action in form. If you keep empty action of form then data will submit on same page
if(isset($_POST["name"]))
{
echo $_POST["name"];
}
<form action="" method="POST">
<input type="text" name="names" id="names">
<input type="submit" value="submit" name="submit_btn">
</form>