• Resolved andixhafa2403

    (@andixhafa2403)


    Hi
    I am trying to insert some php code in a wordpress page. I have a mini form with a input file and a button. I make a request in another page and this page return me something. I want to control if this return the object or not with the code:
    <?php

    if (isset($_GET[“R”]))
    {
    if ($_GET[“R”] == 0)
    {echo ‘Certificate Number does not exist’; }
    if ($_GET[“R”] == 1)
    { echo some variables that came from respons in a get request;}

    } ?>
    the problem is that shows both part and the ‘Certificate Number does not exist’ and the value or variables.
    I have try all code in a file and everything works well.
    Hope to have been clear.
    Thank you in advance 🙂

    https://wordpress.org/plugins/insert-php/

Viewing 4 replies - 1 through 4 (of 4 total)
  • The “Text” tab needs to be used on the editing page, not the “Visual” tab.

    Also, <?php needs to be replaced with [insert_php] and ?> with [/insert_php]. And the echo variable for $_GET[“R”] == 1 needs quotes.

    Try this:

    [insert_php]
    if (isset($_GET["R"]))
    {
    if ($_GET["R"] == 0)
    {echo 'Certificate Number does not exist'; }
    if ($_GET["R"] == 1)
    { echo 'some variables that came from respons in a get request';}
    }
    [/insert_php]

    For testing and to see everything that’s in the $_GET variable, this can be done.

    [insert_php]
    echo print_r($_GET,true);
    [/insert_php]

    Will

    Thread Starter andixhafa2403

    (@andixhafa2403)

    I think that found the problem.
    The server must return me a value of variable R(0 or 1).
    But the print_r($_GET,true) shows me the result:
    Array
    (
    [page_id] => 1988?R=1
    [CertNo] => *********
    [CertType] => *********
    [CertName] => *********
    [CertTitle] => *********
    )
    I add 2 lines of code to get value of R:
    $page_id=$_GET[“page_id”];
    $r=substr($page_id, -1 );
    but it shows nothing.
    Is there any change to remove ? before R and to show &?
    Thank you again

    All that occurs to me at the moment is to change the permalinks setting to something other than “Plain” — something that doesn’t insert a p or page_id GET value.

    Will

    Thread Starter andixhafa2403

    (@andixhafa2403)

    I fix it.
    Thank you very much for your support.
    Best Regards
    Andi Xhafa

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘If condition not working’ is closed to new replies.