How to post data to same page in wordpress

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 Comment

error code: 523