andixhafa2403 on "[Plugin: Insert PHP] If condition not working"

ساخت وبلاگ

andixhafa2403
Member
Posted 10 hours ago #

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 retu me something. I want to control if this retu 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/

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

andixhafa2403
Member
Posted 7 hours ago #

I think that found the problem.
The server must retu 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

andixhafa2403
Member
Posted 11 minutes ago #

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

WordPress ...
ما را در سایت WordPress دنبال می کنید

برچسب : نویسنده : استخدام کار wpss بازدید : 243 تاريخ : يکشنبه 6 تير 1395 ساعت: 4:21