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>

1
1

Do 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>

Leave a Reply

Your email address will not be published. Required fields are marked *