doushen9863 2014-03-25 06:19
浏览 33
已采纳

在wordpress中POST数据

How would I post data from one page to another in wordpress.I have tried with the following form :

<form action="?page_id=25" method="POST">

but then wordpress says page not found when the form is submitted.I then changed permalinks to use %pagename% and still it didn't work,but when I use the url directly it loads the page perfectly.

Is there a different way to POST data in wordpress or is there something I should do so my pages will load?

EDIT

Full code used to submit form

<?php 
    echo '<form id="submitForm" method="POST" action="' . get_permalink(25) . '">';
    echo '<input type="hidden" value="1" name="id">';
    echo '<input type="hidden" value="Test" name="name">';
    echo '<a href="javascript:document.getElementById(\'submitForm\').submit();">View</a>';
    echo '</form>';
?>

The generated code is as follows :

<form id="submitForm" method="POST" action="http://localhost:8888/wp/?page_id=25">
    <input type="hidden" value="1" name="id">
    <input type="hidden" value="Test" name="name">
    <a href="javascript:document.getElementById('submitForm').submit();">View</a>
</form>
  • 写回答

1条回答 默认 最新

  • doupin5667 2014-03-25 06:24
    关注

    use

      <form action="<?php  echo get_permalink(25); ?>" method="POST">
    

    Edit:

    Try Below Code , Wordpress has special meaning of name variable hence change it

        echo '<form id="submitForm" method="POST" action="' . get_permalink(25) . '">';
        echo '<input type="hidden" value="1" name="id">';
        echo '<input type="hidden" value="Test" name="Custom_name">';  // Change the name of the field
        echo '<a href="javascript:document.getElementById(\'submitForm\').submit();">View</a>';
        echo '</form>';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!