最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugin development - How to post data to same page in wordpress

programmeradmin1浏览0评论

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
Add a comment  | 

1 Answer 1

Reset to default 6

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>
发布评论

评论列表(0)

  1. 暂无评论