Jump to content

php file to call a URL and have the URL in an iframe


EddieRock

Recommended Posts

Newbie here again...

 

I'm having difficulty trying to think how to explain this so please bare with me...

 

I'm looking to replace a repeatable url in my website with a php file. This link is a Amazon product link that is in an iframe.

 

All of the code/url in the iframe is the same except for the Amazon ASIN (Product Number)

 

What I want to do is replace the entire "repeatable url" with a php file with and have this code after it ?ASIN= to insert the Amzaon ASIN in the link. After the = sign, I would put the Amazon ASIN. Then when the page loads, the php file will be replaced with the repatable link with the ASIN in it.

 

So, is there a way to replace something like this:

<iframe src="http://rcm.amazon.com/e/cm?t=nikondigitalcamera-20&o=1&p=8&l=as1&asins=B000HJPK0Y&fc1=000000&IS2=1&lt1=_blank&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr" style="width:120px;height:240px;" scrolling="No" marginwidth="0" marginheight="0" frameborder="0"></iframe>

 

with something like this:

<iframe src="product_link.php?ASIN=B000HJPK0Y" width="120" height="240" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>

 

Please note: the B000HJPK0Y in the code above is one of MANY Amazon products. I will be displaying many different products so I would like to have the product_link.php?ASIN= to insert the Amazon product code.

 

Don't forget, I'm a newbie and I really thank you for your help. Can someone reply back with the code I would put in the product_link.php file?

 

thanks a million!

 

EddieRock

~newbie

 

 

This should be in the REGEX forum.  First you need to figure out what stays the same in the amazon URL. 

 

$data = '<iframe src="http://rcm.amazon.com/e/cm?t=nikondigitalcamera-20&o=1&p=8&l=as1&asins=B000HJPK0Y&fc1=000000&IS2=1&lt1=_blank&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr" style="width:120px;height:240px;" scrolling="No" marginwidth="0" marginheight="0" frameborder="0"></iframe>';

preg_match_all("/asins=(.*)&fc1/Uis",$data, $matches);

echo '<iframe src="product_link.php?ASIN='.$matches[1][0].'" width="120" height="240" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>';

 

The above will take out the asin from the URL and put it into your iframe. 

 

 

I tried it and didn't work.

 

Here is what I have in my main file that loads in the browser:

<iframe src="product_link.php?ASIN=B00005LE73" width="120" height="240" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>

 

Here is the code in product_link.php:

<?php 
$data = '<iframe src="http://rcm.amazon.com/e/cm?t=nikondigitalcamera-20&o=1&p=8&l=as1&asins=B000HJPK0Y&fc1=000000&IS2=1&lt1=_blank&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr" style="width:120px;height:240px;" scrolling="No" marginwidth="0" marginheight="0" frameborder="0"></iframe>';

preg_match_all("/asins=(.*)&fc1/Uis",$data, $matches);

echo '<iframe src="product_link.php?ASIN='.$matches[1][0].'" width="120" height="240" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>';
?>

 

and nothing happens. I think the code in the main page may be wrong. Any suggestions?

 

EddieRock

~newbie

 

 

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.