无法获取PHP$_POST变量

时间:2017-09-20 作者:Steve

我们正在使用一个定制的感谢页面,该页面旨在显示一个定制的小册子PDF,具体取决于将您发送到感谢页面的登录页面。

在登录页上,我们使用了一个重力表单,它有一个重定向查询字符串house={embed_post:ID}:enter image description here

这很好用。例如,从一个登录页,提交表单需要http://www.rossnorthhomes.com.au/thank-you/?house=3466

感谢页面模板为:

<?php
/**
 * Template Name: Thank You Page (Custom Template)
 */
$house = $_POST[\'house\'];

$page_sidebar = get_post_meta( $post->ID, \'fave_page_sidebar\', true );
$page_background = get_post_meta( $post->ID, \'fave_page_background\', true );

if( $page_sidebar == \'none\' ) {
    $content_area = \'col-lg-12 col-md-12 col-sm-12 col-xs-12\';
} else if( $page_sidebar == \'left_sidebar\' ) {

    $content_area = \'col-lg-8 col-md-8 col-sm-12 col-xs-12 list-grid-area container-contentbar\';

} else if( $page_sidebar == \'right_sidebar\' ) {
    $content_area = \'col-lg-8 col-md-8 col-sm-12 col-xs-12 container-contentbar\';
}

if( $page_background == \'none\' && $page_sidebar == \'none\' ) {
    $page_bg = \'no-padding-bg\';
}
$sticky_sidebar = houzez_option(\'sticky_sidebar\');
$sidebar_meta = houzez_get_sidebar_meta($post->ID);
?>

<?php get_header(); ?>
    <?php get_template_part( \'template-parts/page\', \'title\' ); ?>

    <section class="section-detail-content houzez-page-template">

        <div class="row">
            <div class="<?php echo esc_attr( $content_area ); ?>">
                <div class="page-main">
                    <div class="white-block <?php echo esc_attr( $page_bg ); ?>">
                        <?php
                        // Start the loop.
                        while ( have_posts() ) : the_post();

                            // Include the page content template.
                            get_template_part( \'content\', \'page\' );

                            // End the loop.
                        endwhile;
                        ?>
                        <?php
                        switch ($house) {
                            case 429: /* The Katherine */
                                echo "<p>Download <a href=\'http://www.rossnorthhomes.com.au/wp-content/uploads/2017/09/The-Katherine-Display.pdf\'>property brochure</a>.</p>";
                                break;
                            case 3466: /* The Beaufort */
                                echo "<p>Download <a href=\'http://www.rossnorthhomes.com.au/wp-content/uploads/2017/09/The-Beaufort-Display.pdf\'>property brochure</a>.</p>";
                                break;
                            case 3481: /* The Merivale */
                                echo "<p>Download <a href=\'http://www.rossnorthhomes.com.au/wp-content/uploads/2017/09/The-Merivale-Display.pdf\'>property brochure</a>.</p>";
                                break;
                        }?>
                    </div>
                </div>
            </div>

            <?php if( $page_sidebar != \'none\' ) { ?>
            <div class="col-lg-4 col-md-4 col-sm-6 col-xs-12 container-sidebar <?php if( $sticky_sidebar[\'page_sidebar\'] != 0 ){ echo \'houzez_sticky\'; }?>">
                <aside id="sidebar" class="sidebar-white">
                    <?php
                    if( $sidebar_meta[\'specific_sidebar\'] == \'yes\' ) {
                        if( is_active_sidebar( $sidebar_meta[\'selected_sidebar\'] ) ) {
                            dynamic_sidebar( $sidebar_meta[\'selected_sidebar\'] );
                        }
                    } else {
                        if( is_active_sidebar( \'page-sidebar\' ) ) {
                            dynamic_sidebar( \'page-sidebar\' );
                        }
                    }
                    ?>
                </aside>
            </div>
            <?php } ?>

        </div>

    </section>

<?php get_footer(); ?>
注:

$house = $_POST[\'house\'];
&;

<?php
    switch ($house) {
        case 3466: /* The Beaufort */
            echo "<p>Download <a href=\'http://www.rossnorthhomes.com.au/wp-content/uploads/2017/09/The-Beaufort-Display.pdf\'>property brochure</a>.</p>";
你能理解为什么没有注入自定义内容吗?i、 e:

<p>Download <a href=\'http://www.rossnorthhomes.com.au/wp-content/uploads/2017/09/The-Beaufort-Display.pdf\'>property brochure</a>.</p>

1 个回复
最合适的回答,由SO网友:Steve 整理而成

我替换了

$house = $_POST[\'house\'];
使用

$house = isset( $_GET[\'house\'] ) ? $_GET[\'house\'] : false;
现在它开始工作了。

结束

相关推荐

Wp-login.php重定向导致注销进程无法工作

我想创建自定义登录、注册、密码重置;注销页面。为此,我在函数中添加了以下代码。php文件。function custom_login_page() { $new_login_page_url = home_url(); // new login page global $pagenow; if( $pagenow == \"wp-login.php\" && $_SERVER[\'REQUEST_METHOD\'] == \'GET\' ) {