Need help with PHP if statement

mpbiz

New member
Apr 29, 2010
2,825
57
0
I have a "thank you" page I show my customers after they successfully convert and place an order.

This thank you page has 2 iframe pixels placed on it.

Both pixels look like this:

Code:
<iframez src="http://tracking.mydomain.com/aff_goal?a=29&goal_id=37" scrolling="no" frameborder="0" width="1" height="1"></iframez>
I need to create a PHP if statement, so that if there is a certain parameter in the URL, then only one of the pixels will be displayed/fire.

Example:

1. What I have now (2 pixels every time):

Code:
<iframez src="http://tracking.mydomain.com/aff_goal?a=29&goal_id=37" scrolling="no" frameborder="0" width="1" height="1"></iframez>
<iframez src="http://tracking.mydomain.com/aff_goal?a=33&goal_id=47" scrolling="no" frameborder="0" width="1" height="1"></iframez>

2. What I need (only 1 pixel every time):

If the parameter "tid=" is in the URL, then ONLY display pixel number one.

If the URL does not have the "tid=" parameter in it, then only display pixel number two.
 


<?php
if(empty($_GET['tid']))
echo '<iframez src="http://tracking.mydomain.com/aff_goal?a=33&goal_id=47" scrolling="no" frameborder="0" width="1" height="1"></iframez>';
else
echo '<iframez src="http://tracking.mydomain.com/aff_goal?a=29&goal_id=37" scrolling="no" frameborder="0" width="1" height="1"></iframez>';
?>
 
  • Like
Reactions: mpbiz
<?php
if(empty($_GET['tid']))
echo '<iframez src="http://tracking.mydomain.com/aff_goal?a=33&goal_id=47" scrolling="no" frameborder="0" width="1" height="1"></iframez>';
else
echo '<iframez src="http://tracking.mydomain.com/aff_goal?a=29&goal_id=37" scrolling="no" frameborder="0" width="1" height="1"></iframez>';
?>

Thanks for the help. Sorry it took me so long to reply, but I just can't get it to work the way I need it to and have been trying everything.

Your code is correct, and all of my code is correct.. I'm 100% sure of that.

The iframe pixel that displays if "tid" is in the URL looks like this:

<iframez src="http://tracking.mydomain.com/aff_goal?a=31&goal_id=59&transaction_id=<? echo $tid; ?>" scrolling="no" frameborder="0" width="1" height="1"></iframez>

But for some reason I just can't get the echo of "tid" to work correctly inside of the iframe. (see bolded area)

It works perfectly if I remove the iframe tags and just use a plain URL though.

So, is there a special way to pull this off when trying to echo the value inside of an iframe?
 
I just realized that when using the script you gave me, it most likely wants to echo the hard coded iframe code BEFORE the "tid" value has been placed in the "transaction_id=" part of the iframe URL.

Any idea how to make both of these work?
 
Nevermind.

The extra tags were causing the error.

Thanks for the help +rep