gpt4 book ai didi

wordpress - 您可以从 Wordpress 页面中访问 POST 变量吗?

转载 作者:行者123 更新时间:2023-12-03 22:20:44 25 4
gpt4 key购买 nike

我在 Wordpress 页面中用 PHP 构建了一个联系表单,使用 exec-php 插件来验证和运行代码。然而,Wordpress 重写系统似乎覆盖了发送到页面的 POSTed 表单数据。有什么办法可以确保这些数据通过?我的 ,htaccess 中只有标准的 WP 重写 block 。

最佳答案

是的,您可以在 Wordpress 的页面中访问 forrm POST 变量。

我创建了一个这样的页面模板:

<?php
/*
Template Name: Page with Form
*/
?>

<?php get_header(); ?>
<div id="content" class="widecolumn">
<?php
var_dump($_POST);

if (have_posts()) : while (have_posts()) : the_post();?>
<div class="post">
<h2 id="post-<?php the_ID(); ?>"><?php the_title();?></h2>
<div class="entrytext">
<?php the_content('<p class="serif">Read the rest of this page &raquo;</p>');?>
</div>
</div>
<?php endwhile; endif; ?>
<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
</div>
<form id="test" method="post">
<input id="srchbox" name="term" size="28" value="" type="text">&nbsp;
<input name="submit" value="Submit" align="absmiddle" type="submit">
</form>
<?php get_footer(); ?>

然后我通过 Wordpress 管理面板创建了一个页面并使用了上面的页面模板。

你可以看到我在这个页面模板中有一个示例表单“测试”。现在,当我在浏览器中访问新创建的页面并在表单中输入一些文本并提交表单时,我得到了 var_dump($_POST); 行:

array(2) {
["term"]=>string(7) "foo-bar"
["submit"]=>string(6) "Submit"
}

如您所见,Wordpress 不会中断任何内容,您的页面可以完全访问表单 POST 变量的 $_POST 数组。

关于wordpress - 您可以从 Wordpress 页面中访问 POST 变量吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5774805/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com