doutang7661 2015-06-23 17:07
浏览 56

在wordpress中获取post方法不起作用

I have made a site in Wordpress.

In my front-page.php and in my index.php files I entered both post and get methods just to echo a message in page-message.php file.

When I click the subscribe button the posts page:news appears.The posts page:news is defined in my Wordpress settings: dashboard=>settings=>reading=>Front page displays=>a static page.

In page-message.php I wanted to show the data I had entered from this form. T

Code for the forms:

<h2>Sign to Newsletter</h2>
<form action="page-message.php" method="post">
    Name:<input class="input" type="text" name="name" value=""/><br/>
    Email:<input type="text" name="email" value=""/>
    <br/><input class="submit" type="submit" value="Subscribe"/>
</form>

Code for page-message.php:

<?php
    $name = $_POST["name"];
    $email = $_POST["email"];
    echo 'Congratulations!You have been successfully subscribed to our newsletter' .$name .$email;                
?>

When I click the subscribe button my url changes to http://localhost/wordpress/page-message.php?name=stergios&email=something%40someone.com.

This seems to be correct when using the post method. The problem is the content!

It always loads the news (posts page from settings =>reading) and not the simple echo message?

It always shows the posts page when I write anything beyond my pages in the url. For example the url localhost/wordpress/hhhhhhhhhhh (a page that does not exist) does load the posts page and not a message error!

  • 写回答

2条回答 默认 最新

  • douji9816 2015-06-23 17:18
    关注

    I know the reason why it is not working.

    action="page-message.php"
    

    your static page's path should be /wp-content/themes/{themename}/page-message.php u can try it,

     action="<?php echo get_template_directory(); ?>/page-message.php"
    

    But I don't think it will work. You can try

     action="/index.php"
    

    It is untested. let me know if it work.

    Update: As you set that page as front page, then your wordpress root url will be that page's url (example.com or example.com/wpdirectory). Then simply do it,

    action="/"
    

    or

    action="/wpdirectory"
    
    评论

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP