WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Passing a parameter to a WordPress page (5 posts)

  1. loothi
    Member
    Posted 6 years ago #

    Hiya,

    Newbie here, I have a newsletter registration page which needs to show the right message depending upon parameters called.

    i.e.

    http://www.mydomain/wp/newsletter/?error=0
    CASE 1:
    Success for registering!

    http://www.mydomain/wp/newsletter/?error=1
    CASE 2:
    We couldn't register you.

    The newsletter page (a "Page" with custom PHP template) does not recognise the parameters.

    Test code in the template is

    <? if ($_GET['error']==1) {
    echo 'ERROR TRUE';
    } else {
    echo 'ERROR FALSE';
    } ?>

    and 'ERROR FALSE' always shows.

    Am I doing something dumb? Any ideas?

    TIA.

  2. whooami
    Member
    Posted 6 years ago #

    obviously the $GET isnt being set.

    <?php
    $mything = ( empty( $_GET['error'] ) ? '' : $_GET['error'] );
    if ($mything == 1)
    {
    echo 'ERROR TRUE'; }
    else {
    echo 'ERROR FALSE';
    } ?>

    try that, it works for me.
    `

  3. loothi
    Member
    Posted 6 years ago #

    Do you have pretty permalinks on (Apache/mod_rewrite)?

  4. loothi
    Member
    Posted 6 years ago #

    Odd. Works if param is called errorz but not error. Oh well, works now, thanks.

  5. whooami
    Member
    Posted 6 years ago #

    error might be an internal variable of some kind to PHP, dunno.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags